手机端返回公司人员列表
This commit is contained in:
parent
80a0ce95a9
commit
085324505f
@ -28,4 +28,11 @@ class BaseApiController extends BaseLikeAdminController
|
||||
$this->userId = $this->request->userInfo['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
public function getPage()
|
||||
{
|
||||
$page = $this->request->get('page', 1);
|
||||
$limit = $this->request->get('limit', 15);
|
||||
return [$page, $limit];
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ namespace app\api\controller;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\auth\SystemRole;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\contract\Contract;
|
||||
use think\facade\Db;
|
||||
@ -17,8 +18,7 @@ class CompanyController extends BaseApiController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$page = $this->request->get('page', 1);
|
||||
$limit = $this->request->get('limit', 15);
|
||||
[$page, $limit] = $this->getPage();
|
||||
$admin = Admin::findOrEmpty($this->userInfo['admin_id']);
|
||||
$myCompany = Company::findOrEmpty($admin['company_id'])->toArray();
|
||||
$companyIds = Contract::where('party_a', $myCompany['id'])->column('party_b');
|
||||
@ -71,4 +71,22 @@ class CompanyController extends BaseApiController
|
||||
return $this->success('success', $data);
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$companyId = $this->request->param('company_id', 0);
|
||||
$query = Admin::where('company_id', $companyId);
|
||||
$count = $query->count();
|
||||
$users = $query->page($page)->limit($limit)->with(['company' => function ($query) {
|
||||
$query->field('id,company_name');
|
||||
}])->field('id,avatar,name,account,phone,qualification,province,city,area,street,is_contract,company_id')->select()->toArray();
|
||||
foreach ($users as &$user) {
|
||||
$roleIds = AdminRole::where('admin_id', $user['id'])->column('role_id');
|
||||
$user['roles'] = SystemRole::whereIn('id', $roleIds)->column('name');
|
||||
$user['qualification'] = $user['qualification'] != null ? json_decode($user['qualification'], true) : [];
|
||||
unset($user['role_id'], $user['dept_id'], $user['jobs_id'], $user['id']);
|
||||
}
|
||||
return $this->success('success', ['count' => $count, 'data' => $users]);
|
||||
}
|
||||
|
||||
}
|
@ -17,8 +17,7 @@ class ContractController extends BaseApiController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$page = $this->request->get('page', 1);
|
||||
$limit = $this->request->get('limit', 15);
|
||||
[$page, $limit] = $this->getPage();
|
||||
$admin = Admin::where('id', $this->userInfo['admin_id'])->find();
|
||||
if (empty($admin)) {
|
||||
return $this->success();
|
||||
|
Loading…
x
Reference in New Issue
Block a user