修改文件、类型显示
This commit is contained in:
1 parent
6f5ffeb8d7
commit
7e9310e4dd
254 files changed
+5412
-4872
No files matched your search
+78
-35
@@ -8,41 +8,73 @@ use app\BaseModel;
|
||||
class Admin extends BaseModel
|
||||
{
|
||||
// 查询所有角色
|
||||
public function search($src)
|
||||
public function search($srcfrom)
|
||||
{
|
||||
// 整理变量
|
||||
$searchval = $src['searchval'];
|
||||
$src = [
|
||||
'searchval' => ''
|
||||
];
|
||||
$src = array_cover($srcfrom, $src);
|
||||
|
||||
// 查询数据
|
||||
$data = $this
|
||||
->order([$src['field'] =>$src['order']])
|
||||
->where('id','>',2)
|
||||
->when(strlen($searchval)>0,function($query) use($searchval){
|
||||
$query->where('xingming|username','like','%'.$searchval.'%');
|
||||
->where('id', '>', 2)
|
||||
->where('id', '<>', session('userid'))
|
||||
->when(strlen($src['searchval']) > 0, function($query) use($src){
|
||||
$query->where('xingming|username', 'like', '%' . $src['searchval'] . '%');
|
||||
})
|
||||
->with([
|
||||
'adSchool'=>function($query){
|
||||
$query->field('id,jiancheng');
|
||||
'adSchool' => function($query){
|
||||
$query->field('id, jiancheng');
|
||||
}
|
||||
,'glGroup'=>function($query){
|
||||
$query->where('status',1)->field('title,rules,miaoshu');
|
||||
,'glGroup' => function($query){
|
||||
$query->where('status', 1)->field('title, rules, miaoshu');
|
||||
}
|
||||
])
|
||||
->hidden(['password','create_time','update_time','delete_time'])
|
||||
])
|
||||
->hidden([
|
||||
'password'
|
||||
,'create_time'
|
||||
,'update_time'
|
||||
,'delete_time'
|
||||
])
|
||||
->select();
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
// 查询用户权限
|
||||
public function srcAuth($user_id)
|
||||
{
|
||||
// 查询权限
|
||||
$data = self::where('id', $user_id)
|
||||
->field('id')
|
||||
->with([
|
||||
'glGroup'
|
||||
])
|
||||
->find();
|
||||
|
||||
// 整理权限
|
||||
$arr = array();
|
||||
foreach ($data->glGroup as $key => $value) {
|
||||
$temp = explode(",", $value->rules);
|
||||
$arr = array_merge($arr, $temp);
|
||||
}
|
||||
$arr = array_unique($arr);
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
public function glGroup()
|
||||
{
|
||||
return $this->belongsToMany('AuthGroup','AuthGroupAccess','group_id','uid');
|
||||
return $this->belongsToMany('AuthGroup', 'AuthGroupAccess', 'group_id', 'uid');
|
||||
}
|
||||
|
||||
|
||||
// 用户角色获取器
|
||||
public function userGroup()
|
||||
{
|
||||
return $this->belongsToMany('AuthGroup','AuthGroupAccess','id','uid');
|
||||
return $this->belongsToMany('AuthGroup', 'AuthGroupAccess', 'id', 'uid');
|
||||
}
|
||||
|
||||
|
||||
@@ -51,35 +83,44 @@ class Admin extends BaseModel
|
||||
{
|
||||
// 查询数据
|
||||
$pasW = $this
|
||||
->where('username',$username)
|
||||
->where('username', $username)
|
||||
->value('password');
|
||||
|
||||
// 返回数据
|
||||
return $pasW;
|
||||
}
|
||||
|
||||
|
||||
// 生日修改器
|
||||
public function setShengriAttr($value)
|
||||
{
|
||||
return strtotime($value);
|
||||
strlen($value) >0 ? $value = strtotime($value) : $value = '';
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
// 生日获取器
|
||||
public function getShengriAttr($value)
|
||||
{
|
||||
return date('Y-m-d',$value);
|
||||
return date('Y-m-d', $value);
|
||||
}
|
||||
|
||||
|
||||
// 创建时间获取器
|
||||
public function getCreateTimeAttr($value)
|
||||
{
|
||||
return date('Y-m-d',$value);
|
||||
return date('Y-m-d', $value);
|
||||
}
|
||||
|
||||
|
||||
// 性别获取器
|
||||
public function getSexAttr($value)
|
||||
{
|
||||
$sex = array('0'=>'女','1'=>'男','2'=>'保密');
|
||||
$sex = [
|
||||
'0' => '女'
|
||||
,'1' => '男'
|
||||
,'2' => '保密'
|
||||
];
|
||||
return $sex[$value];
|
||||
}
|
||||
|
||||
@@ -87,20 +128,22 @@ class Admin extends BaseModel
|
||||
// 最后登录时间取器
|
||||
public function getLasttimeAttr($value)
|
||||
{
|
||||
return date('Y年m月d日 H:i:s',$value);
|
||||
return date('Y年m月d日 H:i:s', $value);
|
||||
}
|
||||
|
||||
|
||||
// 本次登录时间取器
|
||||
public function getThistimeAttr($value)
|
||||
{
|
||||
return date('Y年m月d日 H:i:s',$value);
|
||||
return date('Y年m月d日 H:i:s', $value);
|
||||
}
|
||||
|
||||
|
||||
// 角色关联
|
||||
public function authGroup()
|
||||
{
|
||||
return $this->hasMany('AuthGroupAccess','uid','id')->field('id,uid,group_id');
|
||||
return $this->hasMany('AuthGroupAccess', 'uid', 'id')
|
||||
->field('id, uid, group_id');
|
||||
}
|
||||
|
||||
|
||||
@@ -114,20 +157,22 @@ class Admin extends BaseModel
|
||||
}
|
||||
|
||||
// 查询用户拥有的权限
|
||||
$admininfo = $this->where('id',$userid)
|
||||
->field('id')
|
||||
->with([
|
||||
'glGroup'=>function($query){
|
||||
$query->where('status',1)->field('title');
|
||||
}
|
||||
])
|
||||
->find();
|
||||
$admininfo = $this->where('id', $userid)
|
||||
->field('id')
|
||||
->with([
|
||||
'glGroup'=>function($query){
|
||||
$query->where('status', 1)
|
||||
->field('title');
|
||||
}
|
||||
])
|
||||
->find();
|
||||
|
||||
$groupname = '';
|
||||
foreach ($admininfo->gl_group as $key => $value) {
|
||||
if($key == 0){
|
||||
$groupname = $value->title;
|
||||
}else{
|
||||
$groupname = $groupname.'、'.$value->title;
|
||||
$groupname = $groupname . '、' . $value->title;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,12 +180,10 @@ class Admin extends BaseModel
|
||||
return $groupname;
|
||||
}
|
||||
|
||||
|
||||
// 单位关联模型
|
||||
public function adSchool()
|
||||
{
|
||||
return $this->belongsTo('\app\system\model\School','school','id');
|
||||
return $this->belongsTo('\app\system\model\School', 'school_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user