Переглянути джерело

修复APP功能控制接口问题,请求中间件去掉打印

locky 3 роки тому
батько
коміт
ce7f147a3c
2 змінених файлів з 16 додано та 42 видалено
  1. 13 39
      Controller/AppSetController.py
  2. 3 3
      MiddleWare/requestRecord.py

+ 13 - 39
Controller/AppSetController.py

@@ -58,47 +58,21 @@ class AppSetView(View):
         lang = request_dict.get('lang', None)
         appBundleId = request_dict.get('appBundleId', None)
         if not appBundleId:
-            return response.json(444,'appBundleId')
-        redis = RedisObject()
-
-        if SERVER_TYPE != "Ansjer.formal_settings":
-            key_id= "www"+appBundleId
-        else:
-            key_id = "test" + appBundleId
-        #redis_value = redis.get_data(key=key_id)  去除到缓存中找
-        redis_value = False
-        if redis_value == False:
-            print('添加到缓存')
-            # 查数据库
-            sm_qs = AppSetModel.objects.filter(appBundleId=appBundleId)
-            count = sm_qs.count()
-            if count > 0:
+            return response.json(444, 'appBundleId')
 
-                sm_qs = sm_qs.values("content")
-                # 添加到缓存,缓存时间为3600秒------指的是一个钟后再次访问,就会刷新缓存一次
-                dict_json = json.loads(sm_qs[0]['content'])
-                if 'editionUpgrading' in dict_json :
-                    if  dict_json['editionUpgrading'] == 1:
-                        if lang !='cn':
-                            dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
-                        else:
-                            dict_json['editionUpgrading'] = '正在升级,请稍后登录'
-                    else:
-                        dict_json['editionUpgrading'] = ''
-
-
-
-                content_json_str = dict_json
-
-                redis.set_data(key=key_id, val=content_json_str, expire=3600)
-                # 返回固定值
-                return response.json(0, content_json_str)
+        app_set_qs = AppSetModel.objects.filter(appBundleId=appBundleId).values('content')
+        if not app_set_qs.exists():
+            return response.json(173)
+        dict_json = json.loads(app_set_qs[0]['content'])
+        if 'editionUpgrading' in dict_json:
+            if dict_json['editionUpgrading'] == 1:
+                if lang == 'cn':
+                    dict_json['editionUpgrading'] = '正在升级,请稍后登录'
+                else:
+                    dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
             else:
-                return response.json(173)
-        else:
-            print('去缓存找')
-            # 返回固定值
-            return response.json(0, json.loads(redis_value))
+                dict_json['editionUpgrading'] = ''
+        return response.json(0, dict_json)
 
         # res = {}
         # res['grade'] = 1

+ 3 - 3
MiddleWare/requestRecord.py

@@ -42,10 +42,10 @@ class RequestRecordMiddleware(MiddlewareMixin):
                 }
                 RequestRecordModel.objects.create(**request_record_data)
             elif response.content:     # 处理捕获异常的情况
-                print('content: ', response.content)
+                # print('content: ', response.content)
                 content = eval(str(response.content, 'utf-8'))   # bytes 转为 dict
-                logger = logging.getLogger('info')
-                logger.info('content: {}'.format(content))
+                # logger = logging.getLogger('info')
+                # logger.info('content: {}'.format(content))
                 error_flag = False
                 if 'result_code' in content and content['result_code'] == 500:
                     reason_phrase = content['result']