~~~
/**
* 设置昵称
* @param Request $request
* @return \think\response\Json
*/
public function setNickname(Request $request){
$data = $request->param();
$validate = app(NickNameValidate::class);
$check = $validate->check($data);
if($check != true){
return Response::fail($validate->getError());
}
$result = app(UserService::class)->setNickname($data);
if($result){
$userInfo = app(UserService::class)->findUserById($data['userId']);
return Response::success($userInfo);
}else{
return Response::fail('设置昵称失败');
}
}
~~~