update:更新权限系统
This commit is contained in:
@@ -35,8 +35,18 @@ class Roles extends CatchModel
|
||||
public function getList()
|
||||
{
|
||||
return $this->catchSearch()
|
||||
->with(['permissions', 'departments'])
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->each(function (&$item){
|
||||
$permissions = $item->permissions->column('id');
|
||||
unset($item['permissions']);
|
||||
$item['permissions'] = $permissions;
|
||||
|
||||
$departments = $item->departments->column('id');
|
||||
unset($item['departments']);
|
||||
$item['departments'] = $departments;
|
||||
})
|
||||
->toTree();
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ use catchAdmin\permissions\model\search\UserSearch;
|
||||
use catcher\base\CatchModel;
|
||||
use catcher\exceptions\FailedException;
|
||||
use catcher\Utils;
|
||||
use think\Paginator;
|
||||
|
||||
class Users extends CatchModel
|
||||
{
|
||||
@@ -47,16 +48,25 @@ class Users extends CatchModel
|
||||
* 用户列表
|
||||
*
|
||||
* @time 2019年12月08日
|
||||
* @throws \think\db\exception\DbException
|
||||
* @return \think\Paginator
|
||||
* @return array|\think\Paginator
|
||||
*@throws \think\db\exception\DbException
|
||||
*/
|
||||
public function getList(): \think\Paginator
|
||||
public function getList()
|
||||
{
|
||||
return $this->withoutField(['updated_at'], true)
|
||||
$users = $this->withoutField(['updated_at', 'password', 'remember_token'], true)
|
||||
->catchSearch()
|
||||
->catchLeftJoin(Department::class, 'id', 'department_id', ['department_name'])
|
||||
->with(['jobs', 'roles'])
|
||||
->order($this->aliasField('id'), 'desc')
|
||||
->paginate();
|
||||
->paginate()->toArray();
|
||||
|
||||
foreach ($users['data'] as &$user) {
|
||||
$user['roles'] = array_column($user['roles'], 'id');
|
||||
$user['jobs'] = array_column($user['jobs'], 'id');
|
||||
}
|
||||
|
||||
|
||||
return Paginator::make($users['data'], $users['per_page'], $users['current_page'], $users['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user