songxingwei преди 2 години
родител
ревизия
5c251c6e03
променени са 1 файла, в които са добавени 37 реда и са изтрити 32 реда
  1. 37 32
      app/data/controller/api/auth/Center.php

+ 37 - 32
app/data/controller/api/auth/Center.php

@@ -21,13 +21,10 @@ use hg\apidoc\annotation\Returned;
  */
 class Center extends Auth
 {
-    protected $noNeedLogin=['upload'];
+    protected $noNeedLogin=['upload','image'];
 
 
     /**
-     * 获取用户资料
-     */
-    /**
      * @Title("获取用户资料")
      * @Method("post")
      * @Header("api-name",type="string",require=1,default="",desc="访问类型")
@@ -39,31 +36,14 @@ class Center extends Auth
         $this->success('获取用户资料', $this->getUser());
     }
 
-    /**
-     * 更新用户资料
-     */
-    public function set()
-    {
-        $data = $this->_vali([
-            'headimg.default'       => '',
-            'username.default'      => '',
-            'base_age.default'      => '',
-            'base_sex.default'      => '',
-            'base_height.default'   => '',
-            'base_weight.default'   => '',
-            'base_birthday.default' => '',
-        ]);
-        foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]);
-        if (empty($data)) $this->error('没有修改的数据!');
-        if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) {
-            $this->success('更新资料成功!', $this->getUser());
-        } else {
-            $this->error('更新资料失败!');
-        }
-    }
+
 
     /**
-     * Base64 图片上传
+     * @Title("Base64 图片上传")
+     * @Method("post")
+     * @Header("api-name",type="string",require=1,default="",desc="访问类型")
+     * @Header("api-token",type="string",require=0,default="",desc="token")
+     * @Returned("url",desc="图片地址")
      */
     public function image()
     {
@@ -88,12 +68,14 @@ class Center extends Auth
         }
     }
 
+
     /**
-     * 二进制文件上传
-     * @throws \think\admin\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @Title("二进制图片、文件上传")
+     * @Method("post")
+     * @Header("api-name",type="string",require=1,default="",desc="访问类型")
+     * @Header("api-token",type="string",require=0,default="",desc="token")
+     * @Param("file",type="file",require=1,default="",desc="文件")
+     * @Returned("url",desc="图片地址")
      */
     public function upload()
     {
@@ -112,6 +94,29 @@ class Center extends Auth
     }
 
     /**
+     * 更新用户资料
+     */
+    public function set()
+    {
+        $data = $this->_vali([
+            'headimg.default'       => '',
+            'username.default'      => '',
+            'base_age.default'      => '',
+            'base_sex.default'      => '',
+            'base_height.default'   => '',
+            'base_weight.default'   => '',
+            'base_birthday.default' => '',
+        ]);
+        foreach ($data as $key => $vo) if ($vo === '') unset($data[$key]);
+        if (empty($data)) $this->error('没有修改的数据!');
+        if (DataUser::mk()->where(['id' => $this->uuid])->update($data) !== false) {
+            $this->success('更新资料成功!', $this->getUser());
+        } else {
+            $this->error('更新资料失败!');
+        }
+    }
+
+    /**
      * 获取用户等级
      */
     public function levels()