作者 李宇航

合并分支 'lyh-server' 到 'master'

Lyh server



查看合并请求 !2400
... ... @@ -362,4 +362,16 @@ class Base extends Model
$lists = $lists->toArray();
return $lists;
}
/**
* @remark :根据条件获取单个值
* @name :getValue
* @author :lyh
* @method :post
* @time :2025/7/22 10:00
*/
public function getValue($data,$field = 'id'){
$data = $this->filterRequestData($data);
return $this->formatQuery($data)->value($field);
}
}
... ...
... ... @@ -11,6 +11,8 @@ class ManageHr extends Base
const GID_ZERO = 0;//超级管理员
const STATUS_ONE = 1;
const IS_LEADER = 1;//组长
/**
* 特殊字段
* @return string[]
... ... @@ -202,4 +204,32 @@ class ManageHr extends Base
}
return $name;
}
/**
* @remark :根据当前用户登录的id获取当前用户的组长
* @name :accordIdGetLeader
* @author :lyh
* @method :post
* @time :2025/7/22 9:42
* @param :id->当前用户的人事id
*/
public function accordIdGetLeader($id = 0){
if(empty($id)){
return 0;
}
//查看当前用户是否为组长
$info = $this->read(['id'=>$id],['belong_group','name','is_leader','dept_id','nickname']);
if($info === false){
return 0;
}
//不是组长:根据小组获取组长
if($info['is_leader'] != self::IS_LEADER){
$id = $this->getValue(['belong_group'=>$info['belong_group'],'is_leader'=> self::IS_LEADER]);
if(empty($id)){
//未获取到时,根据当前大组去随机获取一个组长
$id = $this->getValue(['dept_id'=>$info['dept_id'],'is_leader'=> self::IS_LEADER]);
}
}
return $id;
}
}
... ...