Parcourir la source

Merge branch 'master' of http://121.36.46.135:3000/shangshang/jili2

ss il y a 4 mois
Parent
commit
4891bf8908
2 fichiers modifiés avec 21 ajouts et 17 suppressions
  1. 6 0
      api.http
  2. 15 17
      application/common/model/WorkTypeMode.php

+ 6 - 0
api.http

@@ -19,3 +19,9 @@ Content-Type: application/x-www-form-urlencoded
 token=1467914623510020&userId=823&orgId=3
 
 ###
+POST http://jili2.demo.com/api/v1/User/qualityUserList
+Content-Type: application/x-www-form-urlencoded
+
+token=6441914637452703&userId=3361&orgId=3
+
+###

+ 15 - 17
application/common/model/WorkTypeMode.php

@@ -101,28 +101,26 @@ class WorkTypeMode extends Base
      */
     public function getRolesUser($id,$orgId,$work=-1){
         $roles = $this->getRoles($id,$orgId);
-
-
         foreach ($roles as $k=>$v){
             $children = model('Roles')->getChildrenIds($v['id'],$orgId);
-            $user = [];
-            $map = [];
-            if($children){
-                $map[] = ['u.del','=',0];
-                $map[] = ['u.enable','=',1];
-                $map[] = ['ur.roles_id','in',$children];
-                if($work >= 0){
-                    $map[] = ['u.work','=',$work];
-                }
-                $user = Db::name('user_roles')
-                    ->alias('ur')
-                    ->join('user u','u.id = ur.user_id')
-                    ->where($map)
-                    ->field('u.id,u.real_name')
-                    ->select();
+            $children = $children?$children:[]; // 项目角色覆盖,无下级角色,取用户时添加本角色
+            $children[] = $v['id'];
 
+            $map = [];
 
+            $map[] = ['u.del','=',0];
+            $map[] = ['u.enable','=',1];
+            $map[] = ['ur.roles_id','in',$children];
+            if($work >= 0){
+                $map[] = ['u.work','=',$work];
             }
+            $user = Db::name('user_roles')
+                ->alias('ur')
+                ->join('user u','u.id = ur.user_id')
+                ->where($map)
+                ->field('u.id,u.real_name')
+                ->select();
+
             $roles[$k]['user'] = $user?$user:[];
         }
         return $roles;