Commit c44ea657 by 朱继来

调整获取角色

parent 10350010
Showing with 20 additions and 24 deletions
...@@ -135,40 +135,36 @@ ...@@ -135,40 +135,36 @@
// 根据域名查询系统业务ID // 根据域名查询系统业务ID
$business = $this->getBusinessInfo(); $business = $this->getBusinessInfo();
if (!$business) return false;
$userId = array(); $userId = array();
$roleUsers = array(); $roleUsers = array();
if ($business) { $role = DB::table('t_role_perm')->where(['bid' => $business->bid, 'name' => $roleName])->first();
$bid = $business->bid; $roleId = isset($role->roleId) ? $role->roleId : 0;
$role = DB::table('t_role_perm')->where(['bid' => $bid, 'name' => $roleName])->first(); // $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` = $business->bid AND `roles` LIKE '%\"".$roleId."\"%' ORDER BY `mtime`");
$roleId = isset($role->roleId) ? $role->roleId : 0; if (empty($user)) return false;
// $user = DB::select("SELECT * FROM `t_user_perm` WHERE `bid` = $bid AND `roles` REGEXP $roleId"); foreach ($user as $v) {
$user = DB::select("SELECT `userId` FROM `t_user_perm` WHERE `bid` = $bid AND `roles` LIKE '%\"".$roleId."\"%' ORDER BY `mtime`"); $userId[] = $v->userId;
}
if ($user) { if (empty($userId)) return false;
foreach ($user as $v) {
$userId[] = $v->userId;
}
if ($userId) { foreach ($userId as $id) {
foreach ($userId as $id) { $userInfo = DB::table('user_info')->where('userId', $id)->select('userId', 'name', 'email', 'status')->first();
$userInfo = DB::table('user_info')->where('userId', $id)->select('userId', 'name', 'email', 'status')->first();
if (!$userInfo) continue; if (!$userInfo) continue;
// 判断用户是否已离职 4为离职状态 // 判断用户是否已离职 4为离职状态
// if ($userInfo->status != 4) { if ($userInfo->status != 4) {
$roleUsers[] = $userInfo; $roleUsers[] = $userInfo;
// } }
continue; continue;
} }
}
}
}
return $roleUsers; 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