lizhen_gitee 8 hónapja
szülő
commit
32de0404cc

+ 71 - 0
application/api/controller/worker/Baseconfig.php

@@ -0,0 +1,71 @@
+<?php
+
+namespace app\api\controller\worker;
+
+use app\common\controller\Apiw;
+use think\Db;
+/**
+ * 基础配置接口
+ */
+class Baseconfig extends Apiw
+{
+    protected $noNeedLogin = ['*'];
+    protected $noNeedRight = ['*'];
+
+   
+    public function index(){
+
+        $config = [
+            'kefu_user_ids'            => config('site.kefu_user_ids'),//在线客服人员
+            
+        ];
+
+        $this->success('success',$config);
+    }
+
+
+    /**
+     * 获取安卓版本更新信息
+     */
+    public function getandroidEdition() {
+        // 获取二维码
+        $is_force = config("site.android_is_force");
+        $apkUrl = config("site.android_apkUrl");
+        $apkName = config("site.android_apkName");
+        $desc = config("site.android_desc");
+        $versionCode = config("site.android_versionCode");
+        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
+    }
+
+    /**
+     * 获取ios版本更新信息
+     */
+    public function getiosEdition() {
+        // 获取二维码
+        $is_force = config("site.iso_is_force");
+        $apkUrl = config("site.ios_downurl");
+        $apkName = config("site.iso_appname");
+        $desc = config("site.iso_desc");
+        $versionCode = config("site.iso_versioncode");
+        $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
+    }
+
+    //启动广告图
+    public function start_advert(){
+        $info = Db::name('start_advert')->where('is_show',1)->order('id desc')->find();
+        $info = info_domain_image($info,['images','video_file']);
+        $this->success_find('success',$info);
+    }
+
+
+
+    //关键字过滤
+    public function keyworld_config(){
+        $config = config('keyworld');
+        $this->success('success',$config);
+    }
+
+
+
+
+}

+ 0 - 88
application/common/controller/Api.php

@@ -465,93 +465,5 @@ class Api
         }
     }
 
-    //更新用户活跃
-    protected function user_active(){
-        if($this->auth->isLogin()){
-            db('user_active')->where('user_id',$this->auth->id)->update(['requesttime'=>time()]);
-        }
-    }
-
-    //获取用户是否活跃,7200秒,2小时
-    //1活跃,0不活跃
-    protected function user_activeinfo($user_id,$requesttime = 0){
-
-        if(empty($requesttime)){
-            $requesttime = db('user_active')->where('user_id',$user_id)->value('requesttime');
-        }
-
-        $result = [
-            'is_active' => 1,
-            'active_text' => get_last_time($requesttime).'在线',
-        ];
-
-        if(time() - $requesttime > 7200){
-            $result = [
-                'is_active' => 0,
-                'active_text' => '离线',
-            ];
-        }
-
-        return $result;
-    }
-
-    //获取用户是否vip,1是,0否
-    protected function is_vip($user_id){
-        $result = 0;
-
-        $vip_endtime = db('user_wallet')->where('user_id',$user_id)->value('vip_endtime');
-        $result = $vip_endtime > time() ? 1 : 0;
-
-        return $result;
-    }
 
-    //用户是否有某项权限
-    //1有,0没有
-    protected function user_power($user_id,$power = ''){
-        $is_vip = $this->is_vip($user_id);
-        if($is_vip != 1){
-            return 0;
-        }
-        $power = db('user_power')->where('user_id',$user_id)->value($power);
-        return $power;
-
-    }
-
-    //是否关注
-    protected function is_follow($uid,$follow_uid){
-        $where = [
-            'uid' => $uid,
-            'follow_uid' => $follow_uid,
-        ];
-        $check = db('user_follow')->where($where)->find();
-        if($check){
-            return 1;
-        }else{
-            return 0;
-        }
-    }
-
-    //是否拉黑
-    protected function is_black($uid,$black_user_id){
-        $where = [
-            'user_id' => $uid,
-            'black_user_id' => $black_user_id,
-        ];
-        $check = db('user_blacklist')->where($where)->find();
-        if($check){
-            return 1;
-        }else{
-            return 0;
-        }
-    }
-
-    //是否好友
-    protected function is_friend($uid,$follow_uid){
-        $is_follow = $this->is_follow($uid,$follow_uid);
-        $be_follow = $this->is_follow($follow_uid,$uid);
-        if($is_follow && $be_follow){
-            return 1;
-        }
-        return 0;
-    }
 }

+ 48 - 51
application/common/controller/Apiw.php

@@ -14,6 +14,7 @@ use think\Response;
 use think\Route;
 use think\Validate;
 use Redis;
+use app\utils\LogUtil;
 
 /**
  * API控制器基类
@@ -89,12 +90,13 @@ class Apiw
             }
         }
 
-
         // 控制器初始化
         $this->_initialize();
         //日志
         $this->request_log();
 
+
+
         // 前置操作方法
         if ($this->beforeActionList) {
             foreach ($this->beforeActionList as $method => $options) {
@@ -182,7 +184,6 @@ class Apiw
         Lang::load(APP_PATH . $this->request->module() . '/lang/' . $lang . '/' . str_replace('.', '/', $name) . '.php');
     }
 
-
     /**
      * 操作成功返回的数据
      * @param string $msg    提示信息
@@ -233,7 +234,7 @@ class Apiw
     {
         $result = [
             'code' => $code,
-            'msg'  => __($msg),
+            'msg'  => $msg,
             'time' => Request::instance()->server('REQUEST_TIME'),
             'data' => $data,
         ];
@@ -365,6 +366,48 @@ class Apiw
         $this->request->token();
     }
 
+    /**
+     * 接口请求限制
+     * @param int $apiLimit
+     * @param int $apiLimitTime
+     * @param string $key
+     * @return bool | true:通过 false:拒绝
+     */
+    public function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
+    {
+        $userId = $this->auth->id;
+        $controller = request()->controller();
+        $action = request()->action();
+
+        if (!$key) {
+            $key = strtolower($controller) . '_' . strtolower($action) . '_' . $userId;
+        }
+
+        $redis = new Redis();
+        $redisconfig = config("redis");
+        $redis->connect($redisconfig["host"], $redisconfig["port"]);
+        if ($redisconfig['redis_pwd']) {
+            $redis->auth($redisconfig['redis_pwd']);
+        }
+        if($redisconfig['redis_selectdb'] > 0){
+            $redis->select($redisconfig['redis_selectdb']);
+        }
+
+        //
+        //指定键值新增+1 并获取
+        $count = $redis->incr($key);
+        if ($count > $apiLimit) {
+            return false;
+        }
+
+        //设置过期时间
+        if ($count == 1) {
+            $redis->pExpire($key, $apiLimitTime);
+        }
+
+        return true;
+    }
+
     /*
      * api 请求日志
      * */
@@ -406,67 +449,21 @@ class Apiw
     }
 
     protected function request_log_update($log_result){
-        $actionname     = $this->request->action();
-        if(strtolower($actionname) == 'givegifttoyou'){
-            //return true;
-        }
 
         if ($this->logType === 1){
             if (strlen(json_encode($log_result['data'])) > 1000) {
-                //$log_result['data'] = '数据太多,不记录';
+                $log_result['data'] = '数据太多,不记录';
             }
             LogUtil::info('result', 'Api-Middleware-Log', 'request_log', $log_result);
         }else{
             if(defined('API_REQUEST_ID')) { //记录app正常返回结果
                 if(strlen(json_encode($log_result['data'])) > 1000) {
-                    //$log_result['data'] = '数据太多,不记录';
+                    $log_result['data'] = '数据太多,不记录';
                 }
                 db('api_request_log')->where('id',API_REQUEST_ID)->update(['result'=>json_encode($log_result)]);
             }
         }
     }
 
-    /**
-     * 接口请求限制
-     * @param int $apiLimit
-     * @param int $apiLimitTime
-     * @param string $key
-     * @return bool | true:通过 false:拒绝
-     */
-    public function apiLimit($apiLimit = 1, $apiLimitTime = 1000, $key = '')
-    {
-        $userId = $this->auth->id;
-        $controller = request()->controller();
-        $action = request()->action();
-
-        if (!$key) {
-            $key = strtolower($controller) . '_' . strtolower($action) . '_' . $userId;
-        }
-
-        $redis = new Redis();
-        $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
-        if ($redisconfig['redis_pwd']) {
-            $redis->auth($redisconfig['redis_pwd']);
-        }
-        if($redisconfig['redis_selectdb'] > 0){
-            $redis->select($redisconfig['redis_selectdb']);
-        }
-
-        //
-        //指定键值新增+1 并获取
-        $count = $redis->incr($key);
-        if ($count > $apiLimit) {
-            return false;
-        }
-
-        //设置过期时间
-        if ($count == 1) {
-            $redis->pExpire($key, $apiLimitTime);
-        }
-
-        return true;
-    }
-
 
 }