|
@@ -14,8 +14,9 @@ from django.views.generic import TemplateView
|
|
from Ansjer.config import BASE_DIR
|
|
from Ansjer.config import BASE_DIR
|
|
from Ansjer.config import SERVER_DOMAIN
|
|
from Ansjer.config import SERVER_DOMAIN
|
|
from Ansjer.config import SERVER_TYPE
|
|
from Ansjer.config import SERVER_TYPE
|
|
-from Model.models import Device_User
|
|
|
|
|
|
+from Model.models import Device_User, EquipmentVersionLimitModel, CountryIPModel
|
|
from Model.models import Equipment_Version
|
|
from Model.models import Equipment_Version
|
|
|
|
+from Object.RedisObject import RedisObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.ResponseObject import ResponseObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
from Object.UrlTokenObject import UrlTokenObject
|
|
from Object.UrlTokenObject import UrlTokenObject
|
|
@@ -476,8 +477,9 @@ def getNewVerInterface(request):
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
lang = request_dict.get('lang', None)
|
|
lang = request_dict.get('lang', None)
|
|
now_ver = request_dict.get('ver', None)
|
|
now_ver = request_dict.get('ver', None)
|
|
|
|
+ uid = request_dict.get('uid', None)
|
|
if not code or not now_ver:
|
|
if not code or not now_ver:
|
|
- return response.json(902, {'param':'code,ver'})
|
|
|
|
|
|
+ return response.json(902, {'param': 'code,ver'})
|
|
# return response.json(444, 'code,ver')
|
|
# return response.json(444, 'code,ver')
|
|
tko = TokenObject(token)
|
|
tko = TokenObject(token)
|
|
response.lang = tko.lang
|
|
response.lang = tko.lang
|
|
@@ -490,9 +492,38 @@ def getNewVerInterface(request):
|
|
equipmentValid = Equipment_Version.objects.filter(code=code, status=1, lang='en').order_by(
|
|
equipmentValid = Equipment_Version.objects.filter(code=code, status=1, lang='en').order_by(
|
|
'-data_joined')
|
|
'-data_joined')
|
|
|
|
|
|
- print(equipmentValid)
|
|
|
|
if equipmentValid.exists():
|
|
if equipmentValid.exists():
|
|
equipment = equipmentValid[0]
|
|
equipment = equipmentValid[0]
|
|
|
|
+ redisObject = RedisObject(db=3)
|
|
|
|
+ key = 'limit_{eid}'.format(eid=equipment.eid)
|
|
|
|
+
|
|
|
|
+ evl_qs = redisObject.get_data(key=key)
|
|
|
|
+ if evl_qs:
|
|
|
|
+ evl_qs = json.loads(evl_qs)
|
|
|
|
+ else:
|
|
|
|
+ evl_qs = EquipmentVersionLimitModel.objects.filter(equipment_version_id=equipment.eid, status=1).values()
|
|
|
|
+ if evl_qs.exists():
|
|
|
|
+ redisObject.set_data(key=key, val=json.dumps(list(evl_qs.values())), expire=600)
|
|
|
|
+ if evl_qs and len(evl_qs) > 0:
|
|
|
|
+ evl = evl_qs[0]
|
|
|
|
+ if evl['type'] == 1: # uid限制
|
|
|
|
+ uids = json.loads(evl['content'])
|
|
|
|
+ if not uids.__contains__(uid):
|
|
|
|
+ return response.json(902)
|
|
|
|
+ elif evl['type'] == 2: # user限制
|
|
|
|
+ users = json.loads(evl['content'])
|
|
|
|
+ if not users.__contains__(tko.userID):
|
|
|
|
+ return response.json(902)
|
|
|
|
+ elif evl['type'] == 3: # 国家地区限制
|
|
|
|
+ countries = json.loads(evl['content'])
|
|
|
|
+ country_ip_qs = CountryIPModel.objects.filter(user_ex__userID=tko.userID)
|
|
|
|
+ if country_ip_qs.exists():
|
|
|
|
+ country = country_ip_qs[0].country
|
|
|
|
+ else:
|
|
|
|
+ country = CommonService.getAddr(CommonService.get_ip_address(request))
|
|
|
|
+ if not countries.__contains__(country):
|
|
|
|
+ return response.json(902)
|
|
|
|
+
|
|
file_path = equipment.filePath
|
|
file_path = equipment.filePath
|
|
ver = equipment.softwareVersion
|
|
ver = equipment.softwareVersion
|
|
max_ver = equipment.max_ver
|
|
max_ver = equipment.max_ver
|
|
@@ -507,10 +538,10 @@ def getNewVerInterface(request):
|
|
# url = SERVER_DOMAIN + 'dlotapack/' + file_path
|
|
# url = SERVER_DOMAIN + 'dlotapack/' + file_path
|
|
# else:
|
|
# else:
|
|
# 这里调用国内服务器进行下载,防止下载bug
|
|
# 这里调用国内服务器进行下载,防止下载bug
|
|
- # if code == '18E201200CA' or code == '18E201200CZ':
|
|
|
|
- # url = 'http://www.zositech.xyz/dlotapack/' + file_path
|
|
|
|
- # else:
|
|
|
|
- # url = SERVER_DOMAIN + 'dlotapack/' + file_path
|
|
|
|
|
|
+ # if code == '18E201200CA' or code == '18E201200CZ':
|
|
|
|
+ # url = 'http://www.zositech.xyz/dlotapack/' + file_path
|
|
|
|
+ # else:
|
|
|
|
+ # url = SERVER_DOMAIN + 'dlotapack/' + file_path
|
|
return response.json(0, {
|
|
return response.json(0, {
|
|
'ver': ver,
|
|
'ver': ver,
|
|
'url': url,
|
|
'url': url,
|