Commit c44ea657 by 朱继来

调整获取角色

parent 10350010
Showing with 10 additions and 14 deletions
......@@ -135,39 +135,35 @@
// 根据域名查询系统业务ID
$business = $this->getBusinessInfo();
if (!$business) return false;
$userId = array();
$roleUsers = array();
if ($business) {
$bid = $business->bid;
$role = DB::table('t_role_perm')->where(['bid' => $bid, 'name' => $roleName])->first();
$role = DB::table('t_role_perm')->where(['bid' => $business->bid, 'name' => $roleName])->first();
$roleId = isset($role->roleId) ? $role->roleId : 0;
// $user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` REGEXP $roleId");
$user = DB::select("SELECT `userId` FROM `t_user_perm` WHERE `bid` = $bid AND `roles` LIKE '%\"".$roleId."\"%' ORDER BY `mtime`");
$user = DB::select("SELECT `userId` FROM `t_user_perm` WHERE `bid` = $business->bid AND `roles` LIKE '%\"".$roleId."\"%' ORDER BY `mtime`");
if (empty($user)) return false;
if ($user) {
foreach ($user as $v) {
$userId[] = $v->userId;
}
if ($userId) {
if (empty($userId)) return false;
foreach ($userId as $id) {
$userInfo = DB::table('user_info')->where('userId', $id)->select('userId', 'name', 'email', 'status')->first();
if (!$userInfo) continue;
// 判断用户是否已离职 4为离职状态
// if ($userInfo->status != 4) {
if ($userInfo->status != 4) {
$roleUsers[] = $userInfo;
// }
continue;
}
}
}
continue;
}
return $roleUsers;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment