|
...
|
...
|
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside; |
|
|
|
|
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Models\ProjectRole as ProjectRoleModel;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
|
|
|
|
class ProjectRoleController extends BaseController
|
|
...
|
...
|
@@ -44,16 +45,11 @@ class ProjectRoleController extends BaseController |
|
|
|
if($validate->fails()){
|
|
|
|
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
|
|
|
|
}
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
//获取当前项目下的角色超级管理员
|
|
|
|
$projectRoleModel = new ProjectRoleModel();
|
|
|
|
//验证当前角色是否存在
|
|
|
|
if(!isset($this->param['pid'])){
|
|
|
|
$data['pid'] = 0;
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'name' => $this->param['name'],
|
|
|
|
'pid' => $this->param['pid'],
|
|
|
|
];
|
|
|
|
$info = $projectRoleModel->read($data);
|
|
|
|
$info = $projectRoleModel->read(['name'=>$this->param['name']]);
|
|
|
|
if(!empty($info)){
|
|
|
|
$this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
...
|
...
|
@@ -76,28 +72,22 @@ class ProjectRoleController extends BaseController |
|
|
|
$rules = [
|
|
|
|
'id'=>'required',
|
|
|
|
'name'=>'required|max:11',
|
|
|
|
'role_menu'=>'required',
|
|
|
|
];
|
|
|
|
//验证的提示信息
|
|
|
|
$message = [
|
|
|
|
'id.required'=>'主键必须填写',
|
|
|
|
'name.required'=>'名称必须填写',
|
|
|
|
'name.max' => '号码不大于11字符.',
|
|
|
|
'role_menu.required'=>'菜单权限列表填写',
|
|
|
|
];
|
|
|
|
$validate = Validator::make($this->param, $rules, $message);
|
|
|
|
if($validate->fails()){
|
|
|
|
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
|
|
|
|
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
|
|
//验证当前角色是否存在
|
|
|
|
if(!isset($this->param['pid'])){
|
|
|
|
$data['pid'] = 0;
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
//TODO::自动写入当前用户
|
|
|
|
'name' => $this->param['name'],
|
|
|
|
'pid' => $this->param['pid'],
|
|
|
|
];
|
|
|
|
$projectRoleModel = new ProjectRoleModel();
|
|
|
|
$info = $projectRoleModel->read($data);
|
|
|
|
//TODO::查询当前名称是否重复
|
|
|
|
$info = DB::table($projectRoleModel->getTable())->where('id','<>',$this->param['id'])
|
|
|
|
->where(['name'=>$this->param['name'],'project_id'=>$this->user['project_id']])->first();
|
|
|
|
if(!empty($info)){
|
|
|
|
$this->response('当前添加的角色已存在',Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
...
|
...
|
|