超管后台 - 项目子账号列表
This commit is contained in:
@@ -42,5 +42,6 @@ Route::group('', function () {
|
||||
Route::get('detail/:id', 'app\superadmin\controller\company\GetCompanyDetailForUpdateController@index');
|
||||
Route::get('profile/:id', 'app\superadmin\controller\company\GetCompanyDetailForProfileController@index');
|
||||
Route::get('devices', 'app\superadmin\controller\company\GetCompanyDevicesForProfileController@index');
|
||||
Route::get('subusers', 'app\superadmin\controller\company\GetCompanySubusersForProfileController@index');
|
||||
});
|
||||
})->middleware(['app\superadmin\middleware\AdminAuth']);
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace app\superadmin\controller\company;
|
||||
|
||||
use app\common\model\User as UserModel;
|
||||
use library\ResponseHelper;
|
||||
use think\Controller;
|
||||
|
||||
/**
|
||||
* 设备管理控制器
|
||||
*/
|
||||
class GetCompanySubusersForProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* 获取项目下的所有子账号
|
||||
*
|
||||
* @return CompanyModel
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getSubusers(): array
|
||||
{
|
||||
$where = [
|
||||
'companyId' => $this->request->param('companyId/d', 0),
|
||||
'isAdmin' => 0
|
||||
];
|
||||
|
||||
return UserModel::field('id,account,username,avatar,status,createTime,typeId')->where($where)->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公司关联的设备列表
|
||||
*
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$users = $this->getSubusers();
|
||||
|
||||
foreach ($users as &$user) {
|
||||
$user['createTime'] = date('Y-m-d H:i:s', $user['createTime']);
|
||||
}
|
||||
|
||||
return ResponseHelper::success($users);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user