81 lines
1.7 KiB
PHP
81 lines
1.7 KiB
PHP
<?php
|
|
namespace App\Domains\Virtual\Http\Controllers;
|
|
|
|
use App\Core\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Domains\Virtual\Services\CompanyAccountService;
|
|
|
|
class CompanyAccountController extends Controller
|
|
{
|
|
protected $request;
|
|
protected $companyAccountService;
|
|
|
|
/**
|
|
* 构造函数,自动注入.
|
|
*/
|
|
public function __construct(Request $request, CompanyAccountService $companyAccountService)
|
|
{
|
|
$this->request = $request;
|
|
$this->companyAccountService = $companyAccountService;
|
|
}
|
|
|
|
/**
|
|
* 列表.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$conditions = [];
|
|
$conditions['limit'] = $this->request->get('limit', 20);
|
|
|
|
$accounts = $this->companyAccountService->index($conditions);
|
|
|
|
return res($accounts, '账号列表', 201);
|
|
}
|
|
|
|
|
|
/**
|
|
* 创建.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function create()
|
|
{
|
|
$attributes = $this->request->all();
|
|
|
|
$account = $this->companyAccountService->store($attributes);
|
|
|
|
return res($account, '创建成功');
|
|
}
|
|
|
|
/**
|
|
* 编辑.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function update($id)
|
|
{
|
|
$attributes = $this->request->all();
|
|
$attributes['id'] = $id;
|
|
|
|
$account = $this->companyAccountService->store($attributes);
|
|
|
|
return res($account, '修改成功');
|
|
}
|
|
|
|
/**
|
|
* 删除.
|
|
*
|
|
* @return \Illuminate\Http\Response
|
|
*/
|
|
public function destroy()
|
|
{
|
|
$ids = $this->request->ids();
|
|
|
|
$this->companyAccountService->destroy($ids);
|
|
|
|
return res(true, '删除成功');
|
|
}
|
|
}
|