|
@@ -3,10 +3,9 @@
|
|
import json
|
|
import json
|
|
import time
|
|
import time
|
|
|
|
|
|
-from django.db.models import F
|
|
|
|
from django.views import View
|
|
from django.views import View
|
|
|
|
|
|
-from Model.models import RegionModel, CountryModel, LanguageModel, CountryLanguageModel, App_Info
|
|
|
|
|
|
+from Model.models import RegionModel, CountryModel, LanguageModel, CountryLanguageModel
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
from Object.uidManageResponseObject import uidManageResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
@@ -28,11 +27,13 @@ class RegionView(View):
|
|
return self.validate(request_dict, operation)
|
|
return self.validate(request_dict, operation)
|
|
|
|
|
|
def validate(self, request_dict, operation):
|
|
def validate(self, request_dict, operation):
|
|
|
|
+ token = TokenObject(request_dict.get('token', None))
|
|
|
|
+
|
|
response = uidManageResponseObject()
|
|
response = uidManageResponseObject()
|
|
- if operation == 'getCountryAndDomainName':
|
|
|
|
|
|
+
|
|
|
|
+ if operation == 'getCountry':
|
|
return self.get_country(request_dict, response)
|
|
return self.get_country(request_dict, response)
|
|
else:
|
|
else:
|
|
- token = TokenObject(request_dict.get('token', None))
|
|
|
|
if token.code != 0:
|
|
if token.code != 0:
|
|
return response.json(token.code)
|
|
return response.json(token.code)
|
|
|
|
|
|
@@ -253,49 +254,32 @@ class RegionView(View):
|
|
else:
|
|
else:
|
|
return response.json(444)
|
|
return response.json(444)
|
|
|
|
|
|
- @staticmethod
|
|
|
|
- def get_country(request_dict, response):
|
|
|
|
- lang = request_dict.get('lang', None)
|
|
|
|
- app_bundle_id = request_dict.get('app_bundle_id', None)
|
|
|
|
|
|
+ def get_country(self, request_dict, response):
|
|
|
|
+ type = request_dict.get('type', None)
|
|
|
|
+ token = request_dict.get('token', None)
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
time_stamp = request_dict.get('time_stamp', None)
|
|
- time_stamp_token = request_dict.get('time_stamp_token', None)
|
|
|
|
-
|
|
|
|
- if not all([lang, app_bundle_id, time_stamp, time_stamp_token]):
|
|
|
|
- return response.json(444)
|
|
|
|
|
|
|
|
- try:
|
|
|
|
- # 校验时间戳token
|
|
|
|
- time_stamp_token = int(CommonService.decode_data(time_stamp_token))
|
|
|
|
|
|
+ if token and time_stamp and type:
|
|
|
|
+ token = int(CommonService.decode_data(token))
|
|
time_stamp = int(time_stamp)
|
|
time_stamp = int(time_stamp)
|
|
|
|
+
|
|
now_time = int(time.time())
|
|
now_time = int(time.time())
|
|
distance = now_time - time_stamp
|
|
distance = now_time - time_stamp
|
|
- if time_stamp_token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
|
|
|
|
+
|
|
|
|
+ if token != time_stamp or distance > 60000 or distance < -60000: # 为了全球化时间控制在一天内
|
|
return response.json(404)
|
|
return response.json(404)
|
|
|
|
|
|
- # 查询app名
|
|
|
|
- app_inf_qs = App_Info.objects.filter(appBundleId=app_bundle_id).values('appName')
|
|
|
|
- if not app_inf_qs.exists():
|
|
|
|
- return response.json(173)
|
|
|
|
|
|
+ lang_qs = LanguageModel.objects.filter(lang=type)
|
|
|
|
|
|
- lang_qs = LanguageModel.objects.filter(lang=lang)
|
|
|
|
if not lang_qs.exists():
|
|
if not lang_qs.exists():
|
|
lang_qs = LanguageModel.objects.filter(lang='en')
|
|
lang_qs = LanguageModel.objects.filter(lang='en')
|
|
|
|
+
|
|
lang = lang_qs[0]
|
|
lang = lang_qs[0]
|
|
|
|
+ country_qs = CountryLanguageModel.objects.filter(language_id=lang.id).values('country_name', 'country__number')
|
|
|
|
|
|
- # 根据app名返回相应域名
|
|
|
|
- app_name = app_inf_qs[0]['appName']
|
|
|
|
- country_qs = CountryLanguageModel.objects.filter(language_id=lang.id).annotate(
|
|
|
|
- country_number=F('country__number'), push_api=F('country__region__push_api'))
|
|
|
|
- if 'Zosi' in app_name:
|
|
|
|
- country_qs = country_qs.annotate(api=F('country__region__zosi_api'))
|
|
|
|
- elif 'Loocam' in app_name:
|
|
|
|
- country_qs = country_qs.annotate(api=F('country__region__loocam_api'))
|
|
|
|
- else:
|
|
|
|
- country_qs = country_qs.annotate(api=F('country__region__api'))
|
|
|
|
- country_qs = country_qs.values('country_name', 'country_number', 'api', 'push_api')
|
|
|
|
return response.json(0, list(country_qs))
|
|
return response.json(0, list(country_qs))
|
|
- except Exception as e:
|
|
|
|
- return response.json(500, repr(e))
|
|
|
|
|
|
+ else:
|
|
|
|
+ return response.json(444)
|
|
|
|
|
|
def get_country_info(self, userID, request_dict, response):
|
|
def get_country_info(self, userID, request_dict, response):
|
|
# perm = ModelService.check_perm_uid_manage(userID, 0)
|
|
# perm = ModelService.check_perm_uid_manage(userID, 0)
|