|
@@ -95,11 +95,17 @@ class User extends Api
|
|
|
public function edit_user_info()
|
|
|
{
|
|
|
$user = $this->auth->getUser();
|
|
|
- $email = $this->request->post('email');
|
|
|
+ $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
$username = $this->request->post('username');
|
|
|
$gender = $this->request->post('gender');
|
|
|
$birthday = $this->request->post('birthday');
|
|
|
- $avatar = $this->request->post('avatar', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
+ $email = $this->request->post('email');
|
|
|
+ if(empty($avatar) && empty($username) && empty($gender) && empty($birthday) && empty($email)){
|
|
|
+ $this->error('参数错误');
|
|
|
+ }
|
|
|
+ if($avatar){
|
|
|
+ $user->avatar = $avatar;
|
|
|
+ }
|
|
|
if ($username) {
|
|
|
$exists = \app\common\model\User::where('username', $username)->where('id', '<>', $this->auth->id)->find();
|
|
|
if ($exists) {
|
|
@@ -107,12 +113,21 @@ class User extends Api
|
|
|
}
|
|
|
$user->username = $username;
|
|
|
}
|
|
|
- $user->email = $email;
|
|
|
- $user->avatar = $avatar;
|
|
|
- $user->gender = $gender;
|
|
|
- $user->birthday = $birthday;
|
|
|
+ if($gender){
|
|
|
+ $user->gender = $gender;
|
|
|
+ }
|
|
|
+ if($birthday){
|
|
|
+ $user->birthday = $birthday;
|
|
|
+ }
|
|
|
+ if($email){
|
|
|
+ $exists = \app\common\model\User::where('username', $email)->where('id', '<>', $this->auth->id)->find();
|
|
|
+ if ($exists) {
|
|
|
+ $this->error('邮箱已存在');
|
|
|
+ }
|
|
|
+ $user->username = $username;
|
|
|
+ }
|
|
|
$user->save();
|
|
|
- $this->success();
|
|
|
+ $this->success('编辑成功');
|
|
|
}
|
|
|
|
|
|
/**
|