Commit c44ea657 by 朱继来

调整获取角色

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