超管后台 - 项目子账号列表

This commit is contained in:
柳清爽
2025-04-23 17:45:00 +08:00
parent 924425292b
commit 4c72de9309
2 changed files with 46 additions and 0 deletions

View File

@@ -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']);

View File

@@ -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);
}
}