xieruidong 2 years ago
parent
commit
f34e76b0f6
3 changed files with 217 additions and 196 deletions
  1. 21 4
      application/api/controller/qiyu/User.php
  2. 1 5
      application/common/controller/Api.php
  3. 195 187
      public/api.html

+ 21 - 4
application/api/controller/qiyu/User.php

@@ -5,16 +5,28 @@ use app\common\controller\Api;
 use think\Cache;
 
 /**
- * 会员接口
+ * 七鱼接口
  */
 class User extends Api
 {
+    protected $noNeedLogin='*';
+    /**
+     * 获取token
+     * @param string appid
+     * @param string appsecret
+     */
     public function get_token(){
         $config=config('qiyu');
-        $this->_validate([
-            'appid'=>['required',"in:{$config['appid']}"],
-            'appsecret'=>['required',"in:{$config['appSecret']}"],
+        $data=$this->_validate([
+            'appid'=>['require'],
+            'appsecret'=>['require'],
         ]);
+        if($data['appid']!=$config['appid']){
+            $this->error('appid有误');
+        }
+        if($data['appsecret']!=$config['appSecret']){
+            $this->error('appsecret有误');
+        }
         $cacheName="qiyu_crm_token";
         $expire=$config['expire']??7200;
         $token=Cache::remember($cacheName,function (){
@@ -30,9 +42,14 @@ class User extends Api
     {
         $info=[
             'rlt'=>$code?0:1,
+            'msg'=>$msg,
         ];
         $info=array_merge($info,$data);
         json($info)->send();
         exit;
     }
+    protected function error($msg = '', $data = [], $code = 0, $type = null, array $header = [])
+    {
+        $this->success($msg,$data,0);
+    }
 }

+ 1 - 5
application/common/controller/Api.php

@@ -326,11 +326,7 @@ class Api
     }
 
     protected function _validate($rules){
-        if($this->request->isPost()){
-            $data = $this->request->post();
-        }else {
-            $data = input();
-        }
+        $data=array_merge($this->request->get(),$this->request->post()?:[]);
         $this->validate($data,$rules);
         return $data;
     }

File diff suppressed because it is too large
+ 195 - 187
public/api.html


Some files were not shown because too many files changed in this diff