|
@@ -23,13 +23,12 @@ class Role extends Base
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function RoleList(){
|
|
|
- $post =$this->request->post();
|
|
|
+ $post =$this->request->param(["status"=>"","role_name"=>"","createrId"=>"","page"=>1,"size"=>15],"post","trim");
|
|
|
$condition=[];
|
|
|
isset($post['status'])&&$post['status']!=="" ? $condition[]=['status',"=",$post['status']]:"";
|
|
|
isset($post['role_name'])&&$post['role_name']!=="" ? $condition[]=['role_name',"like","%".$post['role_name']."%"]:"";
|
|
|
- isset($post['item'])&&$post['item']!=="" ? $condition[]=["item","=",$post['item']]:"";
|
|
|
isset($post['createrId'])&&$post['createrId']!=="" ? $condition[]=["createrId","=",$post['createrId']]:"";
|
|
|
- $list =$this->model->with(["role_action","company_item"])->where($condition)->order("id","desc")
|
|
|
+ $list =$this->model->with(["role_action"])->where($condition)->order("id","desc")
|
|
|
->paginate(["list_rows"=>$post['size'],"page"=>$post['page']]);
|
|
|
return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
|
|
|
}
|
|
@@ -66,7 +65,7 @@ class Role extends Base
|
|
|
"item"=>"",
|
|
|
];
|
|
|
$role = \app\bug\model\Role::create($list);
|
|
|
- if($role->isEmpty()==false){
|
|
|
+ if($role->isEmpty())throw new \Exception('角色创建失败');
|
|
|
$role_action = [
|
|
|
"role_id"=>$role->id,
|
|
|
"action_conllect"=>$post['action'],
|
|
@@ -76,7 +75,7 @@ class Role extends Base
|
|
|
];
|
|
|
$roleaction=RoleAction::create($role_action);
|
|
|
if($roleaction->isEmpty())throw new \Exception("权限录入失败");
|
|
|
- }throw new \Exception('角色创建失败');
|
|
|
+
|
|
|
$this->model->commit();
|
|
|
return success("角色创建成功");
|
|
|
}catch (\Exception $e){
|
|
@@ -93,7 +92,7 @@ class Role extends Base
|
|
|
public function RoleInfo(){
|
|
|
$roleid =$this->request->post("roleid/d");
|
|
|
if($roleid=="")return error('roleid不能为空');
|
|
|
- $info =$this->model->with(["role_action","company_item"])->findOrEmpty($roleid);
|
|
|
+ $info =$this->model->with(["role_action"])->findOrEmpty($roleid);
|
|
|
if($info->isEmpty())return error("未找到对应的数据");
|
|
|
return success("获取成功",$info);
|
|
|
}
|
|
@@ -184,6 +183,6 @@ class Role extends Base
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
public function RoleAll(){
|
|
|
- return success("获取成功",$this->model->select());
|
|
|
+ return success("获取成功",$this->model->with(['role_action'])->select());
|
|
|
}
|
|
|
}
|