|
@@ -1,23 +1,11 @@
|
|
|
-#!/usr/bin/env python3
|
|
|
-# -*- coding: utf-8 -*-
|
|
|
-"""
|
|
|
-@Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
|
|
|
-@AUTHOR: ASJRD018
|
|
|
-@NAME: AnsjerFormal
|
|
|
-@software: PyCharm
|
|
|
-@DATE: 2020/2/27 9:38
|
|
|
-@Version: python3.6
|
|
|
-@MODIFY DECORD:ansjer dev
|
|
|
-@file: AppSetController.py
|
|
|
-@Contact: chanjunkai@163.com
|
|
|
-"""
|
|
|
+import time
|
|
|
+import json
|
|
|
from Ansjer.config import SERVER_TYPE
|
|
|
from Model.models import AppSetModel, PromotionRuleModel, PopupsConfig, RedDotsConfig
|
|
|
from django.views.generic.base import View
|
|
|
from Object.RedisObject import RedisObject
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Service.ModelService import ModelService
|
|
|
-import time, json
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
|
|
|
|
|
@@ -34,36 +22,32 @@ class AppSetView(View):
|
|
|
|
|
|
def validation(self, request_dict, operation):
|
|
|
response = ResponseObject()
|
|
|
+ token = request_dict.get('token', None)
|
|
|
+ tko = TokenObject(token)
|
|
|
+ if tko.code != 0:
|
|
|
+ return response.json(tko.code)
|
|
|
+ user_id = tko.userID
|
|
|
if operation == 'query':
|
|
|
return self.do_query(request_dict, response)
|
|
|
- if operation == 'admin_query':
|
|
|
- token = request_dict.get('token', None)
|
|
|
- tko = TokenObject(token)
|
|
|
- if tko.code == 0:
|
|
|
- userID = tko.userID
|
|
|
- return self.do_admin_query(userID, request_dict, response)
|
|
|
- else:
|
|
|
- return response.json(tko.code)
|
|
|
+ elif operation == 'page_set': # app弹窗标记红点设置
|
|
|
+ return self.do_page_set(user_id, request_dict, response)
|
|
|
+ elif operation == 'admin_query':
|
|
|
+ return self.do_admin_query(user_id, request_dict, response)
|
|
|
elif operation == 'admin_update':
|
|
|
- token = request_dict.get('token', None)
|
|
|
- tko = TokenObject(token)
|
|
|
- if tko.code == 0:
|
|
|
- userID = tko.userID
|
|
|
- return self.do_admin_update(userID, request_dict, response)
|
|
|
- else:
|
|
|
- return response.json(tko.code)
|
|
|
+ return self.do_admin_update(user_id, request_dict, response)
|
|
|
else:
|
|
|
- token = request_dict.get('token', None)
|
|
|
- tko = TokenObject(token)
|
|
|
- if tko.code == 0:
|
|
|
- userID = tko.userID
|
|
|
- if operation == 'page_set': # app弹窗标记红点设置
|
|
|
- return self.do_page_set(userID, request_dict, response)
|
|
|
- else:
|
|
|
- return response.json(tko.code)
|
|
|
-
|
|
|
- # 查询
|
|
|
- def do_query(self, request_dict, response):
|
|
|
+ return response.json(414)
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def do_query(request_dict, response):
|
|
|
+ """
|
|
|
+ 查询app配置
|
|
|
+ @param request_dict: 请求数据
|
|
|
+ @request_dict lang: 语言
|
|
|
+ @request_dict appBundleId: app包id
|
|
|
+ @param response: 响应
|
|
|
+ @return: response
|
|
|
+ """
|
|
|
lang = request_dict.get('lang', None)
|
|
|
appBundleId = request_dict.get('appBundleId', None)
|
|
|
if not appBundleId:
|
|
@@ -72,6 +56,7 @@ class AppSetView(View):
|
|
|
app_set_qs = AppSetModel.objects.filter(appBundleId=appBundleId).values('content')
|
|
|
if not app_set_qs.exists():
|
|
|
return response.json(173)
|
|
|
+
|
|
|
try:
|
|
|
if not app_set_qs[0]['content']:
|
|
|
return response.json(0)
|
|
@@ -85,39 +70,17 @@ class AppSetView(View):
|
|
|
dict_json['popupsContent'] = json.loads(promotion[0]['popups']).get(lang, '')
|
|
|
dict_json['nowTime'] = int(time.time())
|
|
|
if 'editionUpgrading' in dict_json:
|
|
|
+ dict_json['editionUpgrading'] = ''
|
|
|
if dict_json['editionUpgrading'] == 1:
|
|
|
if lang == 'cn':
|
|
|
dict_json['editionUpgrading'] = '正在升级,请稍后登录'
|
|
|
else:
|
|
|
dict_json['editionUpgrading'] = 'Upgrading, please sign in later'
|
|
|
- else:
|
|
|
- dict_json['editionUpgrading'] = ''
|
|
|
-
|
|
|
return response.json(0, dict_json)
|
|
|
except Exception as e:
|
|
|
- return response.json(500, "错误行数:{errLine}, 错误信息: {errmsg}".format(errLine=e.__traceback__.tb_lineno,
|
|
|
+ return response.json(500, '错误行数:{errLine}, 错误信息: {errmsg}'.format(errLine=e.__traceback__.tb_lineno,
|
|
|
errmsg=repr(e)))
|
|
|
|
|
|
- # res = {}
|
|
|
- # res['grade'] = 1
|
|
|
- # # # 用户帮助
|
|
|
- # res['usingHelp'] = 0
|
|
|
- # # # AP添加方式
|
|
|
- # res['apAdd'] = 1
|
|
|
- # # # AP工具
|
|
|
- # res['apTool'] = 1
|
|
|
- # # # 广告模块
|
|
|
- # res['ad_module'] = {
|
|
|
- # "time": 0,
|
|
|
- # "ad_path": [
|
|
|
- # "https://test.dvema.com/web/static/image/default_ad1",
|
|
|
- # "https://test.dvema.com/web/static/image/default_ad2",
|
|
|
- # "https://test.dvema.com/web/static/image/default_ad3",
|
|
|
- # ]
|
|
|
- # }
|
|
|
- # res['init_img'] = 'https://test.dvema.com/web/static/image/default_start'
|
|
|
- # return response.json(0, res)
|
|
|
-
|
|
|
def do_admin_query(self, userID, request_dict, response):
|
|
|
# 查询和添加权限
|
|
|
own_perm = ModelService.check_perm(userID, 40)
|