|
@@ -4,7 +4,7 @@
|
|
|
namespace app\bug\controller;
|
|
|
|
|
|
|
|
|
-use think\App;use think\facade\Validate;
|
|
|
+use app\bug\model\WorkUser;use app\user\model\Account;use think\App;use think\facade\Validate;
|
|
|
class WorkRole extends Base{
|
|
|
public function __construct(App $app) {
|
|
|
parent::__construct($app);
|
|
@@ -88,4 +88,46 @@ class WorkRole extends Base{
|
|
|
$list =$this->model->where($where)->order('id desc')->paginate(['list_rows'=>$param['size'],'page'=>$param['page']]);
|
|
|
return success('获取成功',['list'=>$list->items(),'count'=>$list->total()]);
|
|
|
}
|
|
|
+
|
|
|
+ public function WorkRoleCreate(){
|
|
|
+ $param=$this->request->param(["account_id"=>"","role_id"=>""],"post","trim");
|
|
|
+ $valid = Validate::rule([
|
|
|
+ "account_id|账户ID"=>"require|number|gt:0",
|
|
|
+ "role_id|岗位角色Id"=>"require|number|gt:0"
|
|
|
+ ]);
|
|
|
+ if($valid->check($param)==false) return error($valid->getError());
|
|
|
+ $userinfo = Account::with(["userInfo"])->where(["is_del"=>0])->findOrEmpty($param['account_id']);
|
|
|
+ if($userinfo->isEmpty())return error("用户信息不存在");
|
|
|
+ $roleInfo = $this->model->findOrEmpty($param['role_id']);
|
|
|
+ if($roleInfo->isEmpty())return error('角色信息不存在');
|
|
|
+ $data=[
|
|
|
+ "account_id"=>$param['account_id'],
|
|
|
+ "role_id" => $param['account_id'],
|
|
|
+ 'apply_id'=>$this->uid,
|
|
|
+ 'apply_name'=>$this->uname,
|
|
|
+ ];
|
|
|
+ $add =WorkUser::create($data);
|
|
|
+ return $add ? success('账户角色设置成功'):error('账户角色设置失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function WorkRoleSave(){
|
|
|
+ $param=$this->request->param(['id'=>'',"account_id"=>"",'role_id'=>''],'post','trim');
|
|
|
+ $valid = Validate::rule([
|
|
|
+ 'id|账户角色ID'=>'require|number|gt:0',
|
|
|
+ 'account_id|账户ID'=>'require|number|gt:0',
|
|
|
+ 'role_id|岗位角色Id'=>'require|number|gt:0'
|
|
|
+ ]);
|
|
|
+ if($valid->check($param)==false) return error($valid->getError());
|
|
|
+ $info = WorkUser::where(["id"=>$param['id']])->findOrEmpty();
|
|
|
+ if($info->isEmpty())return error('账户角色信息不存在');
|
|
|
+ if($info->status!=0)return error('账户角色状态不可修改');
|
|
|
+ $userinfo = Account::with(['userInfo'])->where(['is_del'=>0])->findOrEmpty($param['account_id']);
|
|
|
+ if($userinfo->isEmpty())return error('用户信息不存在');
|
|
|
+ $roleInfo = $this->model->findOrEmpty($param['role_id']);
|
|
|
+ if($roleInfo->isEmpty())return error('角色信息不存在');
|
|
|
+ $info->account_id=$param['account_id'];
|
|
|
+ $info->role_id=$param['role_id'];
|
|
|
+ $add = $info->save();
|
|
|
+ return $add ? success('账户角色设置成功'):error('账户角色设置失败');
|
|
|
+ }
|
|
|
}
|