用户列表

This commit is contained in:
小松树 committed 2019-04-10 16:54:46 +08:00
1 parent fa826e0c83
commit 781c5f891d
6 files changed
+186 -248

No files matched your search

+62 -37
View File
@@ -7,6 +7,31 @@ use app\common\model\Base;
class Admin extends Base
{
// 查询所有角色
public function search($src)
{
// 整理变量
$searchval = $src['searchval'];
// 查询数据
$data = $this
->order([$src['field'] =>$src['order']])
->when(strlen($searchval)>0,function($query) use($searchval){
$query->where('xingming','like','%'.$searchval.'%');
})
->with([
'adSchool'=>function($query){
$query->field('id,jiancheng');
}
// ,'authGroup'=>function($query){
// }
])
->select();
return $data;
}
// 用户角色获取器
public function userGroup()
{
@@ -52,58 +77,58 @@ class Admin extends Base
}
// 最后登录获取器
// 最后登录时间取器
public function getLasttimeAttr($value)
{
return date('Y年m月d日 h:i:s',$value);
}
// 权限关联
public function authgroup()
// 角色关联
public function authGroup()
{
return $this->hasMany('AuthGroupAccess','uid','id')->field('id,uid,group_id');
}
// 获取角色id表
public function getGroupidsAttr()
{
// 获取当前当前管理员信息
$admin = $this->get($this->getAttr('id'));
// 获取角色id
$list = $admin->authgroup()->column('group_id');
// // 获取角色id表
// public function getGroupidsAttr()
// {
// // 获取当前当前管理员信息
// $admin = $this->get($this->getAttr('id'));
// // 获取角色id
// $list = $admin->authgroup()->column('group_id');
$str = '';
// 将角色id转换成数组
foreach ($list as $key => $value) {
$key == 0 ? $str =$value : $str = $str.','.$value;
}
// $str = '';
// // 将角色id转换成数组
// foreach ($list as $key => $value) {
// $key == 0 ? $str =$value : $str = $str.','.$value;
// }
// 返回值
return $str;
}
// // 返回值
// return $str;
// }
// 获取角色名称
public function getGroupnamesAttr()
{
// 获取角色id
$group = $this->get($this->getAttr('id'))->append(['groupids']);
// // 获取角色名称
// public function getGroupnamesAttr()
// {
// // 获取角色id
// $group = $this->get($this->getAttr('id'))->append(['groupids']);
$str = '';
// 查询角色名称
$grouplist= db('AuthGroup')->where('id','in',$group->groupids)->column('title');
// 重组角色名
foreach ($grouplist as $key => $value) {
if($key == 0){
$str = $value;
}else{
$str = $str.'、'.$value;
}
}
// 返回角色名
return $str;
}
// $str = '';
// // 查询角色名称
// $grouplist= db('AuthGroup')->where('id','in',$group->groupids)->column('title');
// // 重组角色名
// foreach ($grouplist as $key => $value) {
// if($key == 0){
// $str = $value;
// }else{
// $str = $str.'、'.$value;
// }
// }
// // 返回角色名
// return $str;
// }
// 单位关联模型
public function adSchool()