|
...
|
...
|
@@ -20,7 +20,8 @@ class UserController extends BaseController |
|
|
|
public function lists(){
|
|
|
|
//TODO::搜索参数处理
|
|
|
|
$userModel = new UserModel();
|
|
|
|
$lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile']);
|
|
|
|
$this->map['project_id'] = $this->user['project_id'];
|
|
|
|
$lists = $userModel->lists($this->map,$this->p,$this->row,$this->order,['id','name','mobile','created_at']);
|
|
|
|
if(empty($lists)){
|
|
|
|
$this->response('请求失败',Code::USER_ERROR,[]);
|
|
|
|
}
|
|
...
|
...
|
@@ -39,6 +40,7 @@ class UserController extends BaseController |
|
|
|
'mobile'=>'required|string|max:11',
|
|
|
|
'password'=>'required|string|min:5',
|
|
|
|
'name'=>'required|max:20',
|
|
|
|
'role_id'=>'required'
|
|
|
|
];
|
|
|
|
//验证的提示信息
|
|
|
|
$message = [
|
|
...
|
...
|
@@ -50,13 +52,15 @@ class UserController extends BaseController |
|
|
|
'password.min' => '密码不小于5字符.',
|
|
|
|
'name.required'=>'名称必须填写',
|
|
|
|
'name.min' => '名称不小于5字符.',
|
|
|
|
'role_id.required'=>'角色必须填写',
|
|
|
|
];
|
|
|
|
$validate = Validator::make($this->param, $rules, $message);
|
|
|
|
if($validate->fails()){
|
|
|
|
return $this->response($validate->errors()->first(),Code::USER_LOGIN_ERROE,$this->param);
|
|
|
|
}
|
|
|
|
$userLogic = new UserLogic();
|
|
|
|
$rs = $userLogic->add($this->param);
|
|
|
|
$userModel = new UserModel();
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$rs = $userModel->adds($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->response('当前添加用户已存在或参数错误,添加失败',Code::USER_REGISTER_ERROE,[]);
|
|
|
|
}
|
|
...
|
...
|
@@ -92,8 +96,14 @@ class UserController extends BaseController |
|
|
|
if($validate->fails()){
|
|
|
|
return $this->response($validate->errors()->first(),Code::USER_PARAMS_ERROE,$this->param);
|
|
|
|
}
|
|
|
|
$userLogic = new UserLogic();
|
|
|
|
$rs = $userLogic->edits($this->param);
|
|
|
|
$userModel = new UserModel();
|
|
|
|
//TODO::查询当前手机号码是否重复
|
|
|
|
$info = $userModel->where('id','<>',$this->param['id'])
|
|
|
|
->where(['mobile'=>$this->param['mobile']])->first();
|
|
|
|
if(!empty($info)){
|
|
|
|
$this->response('当前编辑的手机号码已存在',Code::USER_PARAMS_ERROE);
|
|
|
|
}
|
|
|
|
$rs = $userModel->edits($this->param);
|
|
|
|
if($rs === false){
|
|
|
|
$this->response('参数错误或其他服务器原因,编辑失败',Code::USER_ERROR,[]);
|
|
|
|
}
|
...
|
...
|
|