|
@@ -2,12 +2,12 @@
|
|
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
-use think\Db;
|
|
|
-use app\common\model\User;
|
|
|
+use app\common\model\Department;
|
|
|
+use app\common\service\ApproveService;
|
|
|
use hg\apidoc\annotation as Apidoc;
|
|
|
|
|
|
/**
|
|
|
- * @Apidoc\Title("个人中心")
|
|
|
+ * @Apidoc\Title("我的")
|
|
|
* @Apidoc\Group("api")
|
|
|
* @Apidoc\Sort("2")
|
|
|
*/
|
|
@@ -23,61 +23,82 @@ class Member extends Base
|
|
|
* 获取个人信息
|
|
|
*
|
|
|
* @Apidoc\Method("POST")
|
|
|
- * @Apidoc\Returned("phone", type="int", desc="手机号")
|
|
|
- * @Apidoc\Returned("name", type="string", desc="姓名")
|
|
|
+ * @Apidoc\Returned("avatar", type="string", desc="头像地址")
|
|
|
* @Apidoc\Returned("nickname", type="string", desc="昵称")
|
|
|
- * @Apidoc\Returned("headimg", type="string", desc="头像地址")
|
|
|
- * @Apidoc\Returned("title", type="string", desc="职称")
|
|
|
+ * @Apidoc\Returned("name", type="string", desc="姓名")
|
|
|
+ * @Apidoc\Returned("mobile", type="string", desc="手机号码")
|
|
|
* @Apidoc\Returned("department", type="string", desc="部门(多个部门以逗号分隔)")
|
|
|
+ * @Apidoc\Returned("title", type="string", desc="职位")
|
|
|
* @Apidoc\Returned("signature", type="string", desc="个人签名")
|
|
|
+ * @Apidoc\Returned("department_list", type="array", desc="部门列表")
|
|
|
*/
|
|
|
public function user_info()
|
|
|
{
|
|
|
$user = $this->user;
|
|
|
- $this->success('获取成功',$user);
|
|
|
+ $info['avatar'] = $user['avatar'];
|
|
|
+ $info['nickname'] = $user['nickname'];
|
|
|
+ $info['name'] = $user['name'];
|
|
|
+ $info['mobile'] = $user['mobile'];
|
|
|
+ $info['department'] = $user['department'];
|
|
|
+ $info['title'] = $user['title'];
|
|
|
+ $info['signature'] = $user['signature'];
|
|
|
+ $info['department_list'] = Department::field('dept_id,name')->where('dept_id', 'in', $user['department'])->select();
|
|
|
+ $this->success('获取成功', $info);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑个人信息
|
|
|
*
|
|
|
* @Apidoc\Method("POST")
|
|
|
- * @Apidoc\Param("type", type="int", require=true, desc="修改的类型(1:昵称,2:签名,3:手机号)")
|
|
|
- * @Apidoc\Param("nickname", type="string", desc="昵称")
|
|
|
- * @Apidoc\Param("signature", type="string", desc="签名")
|
|
|
- * @Apidoc\Param("phone", type="string", desc="手机号")
|
|
|
+ * @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()
|
|
|
{
|
|
|
- $uid = $this->user_id;
|
|
|
- $type = input('type');
|
|
|
+ $avatar = input('avatar');
|
|
|
$nickname = input('nickname');
|
|
|
+ $mobile = input('mobile');
|
|
|
$signature = input('signature');
|
|
|
- $phone = input('phone');
|
|
|
- if(!in_array($type,[1,2,3])){
|
|
|
- $this->error('参数错误');
|
|
|
+
|
|
|
+ $data = [];
|
|
|
+ if ($avatar) {
|
|
|
+ $data['avatar'] = $avatar;
|
|
|
}
|
|
|
- if($type == 1){
|
|
|
- if(empty($nickname)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $update_data['nickname'] = $nickname;
|
|
|
- }elseif ($type == 2){
|
|
|
- if(empty($signature)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- $update_data['signature'] = $signature;
|
|
|
- }elseif ($type == 2){
|
|
|
- if(empty($phone)){
|
|
|
- $this->error('参数错误');
|
|
|
- }
|
|
|
- if(!preg_match("/^1[23456789]\d{9}$/", $phone)){
|
|
|
+ if ($nickname) {
|
|
|
+ $data['nickname'] = $nickname;
|
|
|
+ }
|
|
|
+ if (!empty($mobile)) {
|
|
|
+ if (!preg_match("/^1[23456789]\d{9}$/", $mobile)) {
|
|
|
$this->error('手机号格式不正确');
|
|
|
}
|
|
|
- $update_data['phone'] = $phone;
|
|
|
+ $data['mobile'] = $mobile;
|
|
|
+ }
|
|
|
+ if ($signature) {
|
|
|
+ $data['signature'] = $signature;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($data) {
|
|
|
+ $user = $this->user;
|
|
|
+ $user->save($data);
|
|
|
}
|
|
|
- Db::name('store_member')->where('id',$uid)->update($update_data);
|
|
|
$this->success('编辑成功');
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 审批待处理统计
|
|
|
+ *
|
|
|
+ * @Apidoc\Method("POST")
|
|
|
+ * @Apidoc\Returned("module", type="integer", desc="模块类型:1=申购申请,2=呈批申请,3=入库申请,4=领用申请,5=出差申请,6=请假申请,7=用车申请,8=维修申请,9=合同呈批,10=收文批阅,11=学校文件")
|
|
|
+ * @Apidoc\Returned("module_text", type="string", desc="模块类型描述")
|
|
|
+ * @Apidoc\Returned("number", type="integer", desc="待处理数量")
|
|
|
+ **/
|
|
|
+ public function get_count(){
|
|
|
+ $user = $this->user;
|
|
|
+ $data = ApproveService::get_count($user);
|
|
|
+ $this->success('审批待处理统计', $data);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|