wugg 8 mesi fa
parent
commit
79e1137cda

+ 37 - 1
app/admin/controller/Base.php

@@ -3,7 +3,8 @@ declare (strict_types = 1);
 
 namespace app\admin\controller;
 
-use app\BaseController;
+use app\admin\model\RoleGroup;
+use app\admin\model\RoleShare;use app\BaseController;
 use think\App;
 
 class Base extends BaseController
@@ -40,4 +41,39 @@ class Base extends BaseController
    	  	if($this->roleid==='') throw new \Exception( '没有该公司的角色','101');
    	   }
    }
+   public function checkRole(){
+      $action = [
+                      'action_conllect'=>'',
+                      'write'=>[],
+                      'platform'=>[],
+                      'roleid'=>$this->roleid
+                  ];
+      if($this->level==2){
+          $roleinfo =\app\admin\model\RoleAction::where('roleid',$this->roleid)->findOrEmpty();
+          $action['action_conllect'] = $roleinfo->action_conllect;
+          $action['write'][] = $this->uid;
+          $group= RoleGroup::whereFindInSet('group_user',$this->uid)->column("id");
+          $where = ["to_user"=>$this->uid];
+          if(!empty($group)){
+              $where['to_group'] =$group;
+          }
+          $platform = \app\admin\model\UserPlatform::where(['uid' => $this->uid, 'is_del' => 0])->findOrEmpty();
+          $action['platform'] = $platform->platform??[];
+          $share = RoleShare::where(['is_del' => 0, 'status' => 1])->whereOr($where)->select();
+          if(!$share->isEmpty()){
+              $share->each(function ($item) use (&$action) {
+                    switch ($item->action) {
+                        case 1:
+                            if($item->share_user==''){
+                                $action['write'][] =$item->share_user;
+                                $user = \app\admin\model\UserRole::where(["uid"=>$item->share_user,"is_del"=>0,"status"=>1])->findOrEmpty();
+                                if(!$user->isEmpty()){
+                                    $action['write'][] =$user->roleid;
+                                }
+                            }
+                    }
+              });
+          }
+      }
+   }
 }

+ 4 - 1
app/admin/controller/Platform.php

@@ -4,7 +4,10 @@
 namespace app\admin\controller;
 
 
-use app\admin\model\PlatformSource;use app\admin\model\UserPlatform;use think\App;use think\facade\Validate;
+use app\admin\model\PlatformSource;
+use app\admin\model\UserPlatform;
+use think\App;
+use think\facade\Validate;
 class Platform extends Base{
     public function __construct(App $app) {
         parent::__construct($app);

+ 0 - 1
app/admin/model/RoleGroup.php

@@ -13,6 +13,5 @@ class RoleGroup extends Base
         'is_del'       =>'int',//是否删除
         'addtime'       =>'datetime',//
         'updatetime'       =>'datetime',//
-
     ];
 }

+ 1 - 1
app/user/controller/Depart.php

@@ -52,7 +52,7 @@ class Depart extends Base{
 		        ]);
 			
 			if ($val->check($param) == false) return error( $val->getError());
-			$depart_link="";
+			$depart_link=[];
 			if($param['pid']!=0){
 				$parent = $this->model->findOrEmpty($param['pid']);
 				if($parent->isEmpty())return error("未找到父级部门信息");