user; unset($user['status'],$user['is_deleted'],$user['create_at']); $department_data = UserService::get_user_department_list($user['department']);; $user['department_list'] = $department_data; $user['subject'] = sysconf('subject'); $user['subject_image'] = sysconf('subject_image'); $this->success('获取成功', $user); } /** * 编辑个人信息 * * @Apidoc\Method("POST") * @Apidoc\Param("type", type="integer", require=true, desc="类型:1=头像地址,2=昵称,3=手机号码,4=签名") * @Apidoc\Param("avatar", type="string", require=false, desc="头像地址") * @Apidoc\Param("nickname", type="string", require=false, desc="昵称") * @Apidoc\Param("mobile", type="string", require=false, desc="手机号码") * @Apidoc\Param("signature", type="string", require=false, desc="签名") */ public function edit() { $type = input('type') ?: 0; $avatar = input('avatar') ?: ''; $nickname = input('nickname') ?: ''; $mobile = input('mobile') ?: ''; $signature = input('signature') ?: ''; $data = []; switch ($type){ case 1: if (!$avatar) { $this->error('请上传头像'); } break; case 2: if (!$nickname) { $this->error('请输入昵称'); } break; case 3: if (!preg_match("/^1[23456789]\d{9}$/", $mobile)) { $this->error('手机号格式不正确'); } break; case 4: if (!$signature) { $this->error('请上传签名'); } break; } if ($avatar) { $data['avatar'] = $avatar; } if ($nickname) { $data['nickname'] = $nickname; } if ($mobile) { if (!preg_match("/^1[23456789]\d{9}$/", $mobile)) { $this->error('手机号格式不正确'); } $data['mobile'] = $mobile; } if ($signature) { $data['signature'] = $signature; $data['signature_status'] = CommonConstant::SIGNATURE_STATUS_2; } if ($data) { $user = $this->user; $user->save($data); } $this->success('编辑成功'); } }