|
@@ -29,6 +29,50 @@ class SystemUserLogic extends BaseLogic
|
|
|
$this->model = new SystemUser();
|
|
$this->model = new SystemUser();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getList($query): mixed
|
|
|
|
|
+ {
|
|
|
|
|
+ $saiType = request()->input('saiType', 'list');
|
|
|
|
|
+ $page = request()->input('page', 1);
|
|
|
|
|
+ $limit = request()->input('limit', 10);
|
|
|
|
|
+ $orderBy = request()->input('orderBy', '');
|
|
|
|
|
+ $orderType = request()->input('orderType', $this->orderType);
|
|
|
|
|
+ if(empty($orderBy)) {
|
|
|
|
|
+ $orderBy = $this->orderField !== '' ? $this->orderField : $this->model->getPk();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果排序字段是id,明确指定表名避免歧义
|
|
|
|
|
+ if($orderBy === 'id') {
|
|
|
|
|
+ $orderBy = 'sa_system_user.id';
|
|
|
|
|
+ }
|
|
|
|
|
+ $query->field([
|
|
|
|
|
+ 'sa_system_user.id' => 'id',
|
|
|
|
|
+ 'sa_system_user.nickname' => 'nickname',
|
|
|
|
|
+ 'sa_system_user.username' => 'username',
|
|
|
|
|
+ 'sa_system_user.phone' => 'phone',
|
|
|
|
|
+ 'sa_system_user.email' => 'email',
|
|
|
|
|
+ 'sa_system_user.status' => 'status',
|
|
|
|
|
+ 'sa_system_user.dept_id' => 'dept_id',
|
|
|
|
|
+ 'sa_system_user.create_time' => 'create_time',
|
|
|
|
|
+ 'sa_system_dept.name' => 'dept_name',
|
|
|
|
|
+ 'GROUP_CONCAT(sa_system_user_role.role_id)' => 'role_id',
|
|
|
|
|
+ 'GROUP_CONCAT(sa_system_role.name)' => 'role_name'
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $query->leftJoin('sa_system_user_role', 'sa_system_user.id = sa_system_user_role.user_id');
|
|
|
|
|
+ $query->leftJoin('sa_system_dept', 'sa_system_user.dept_id = sa_system_dept.id');
|
|
|
|
|
+ $query->leftJoin('sa_system_role', 'sa_system_user_role.role_id = sa_system_role.id');
|
|
|
|
|
+ $query->group('sa_system_user.id');
|
|
|
|
|
+ $query->order($orderBy, $orderType);
|
|
|
|
|
+ if ($saiType === 'all') {
|
|
|
|
|
+ return $query->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return $query->paginate($limit, false, ['page' => $page])->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 读取数据
|
|
* 读取数据
|
|
|
* @param $id
|
|
* @param $id
|