|
@@ -12,6 +12,7 @@
|
|
|
@Contact: chanjunkai@163.com
|
|
|
"""
|
|
|
import base64
|
|
|
+import json
|
|
|
import threading
|
|
|
import urllib.parse
|
|
|
import time
|
|
@@ -22,6 +23,7 @@ from django.views.decorators.csrf import csrf_exempt
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
|
|
|
from Model.models import Device_Info
|
|
|
from Object.ETkObject import ETkObject
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Service.ModelService import ModelService
|
|
|
from Service.CommonService import CommonService
|
|
@@ -111,7 +113,13 @@ def getTZ(request):
|
|
|
uid = c.decode('utf-8')
|
|
|
if len(uid) == 20:
|
|
|
print(uid)
|
|
|
- if update:
|
|
|
+ redisObject = RedisObject(db=7)
|
|
|
+ data = redisObject.get_data(key=ip)
|
|
|
+
|
|
|
+ if data:
|
|
|
+ info = json.loads(data)
|
|
|
+ return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
|
|
|
+ elif update:
|
|
|
info = CommonService.getIpIpInfo(ip=ip, lang=lang,update=True)
|
|
|
else:
|
|
|
info = CommonService.getIpIpInfo(ip=ip, lang=lang,update=False)
|
|
@@ -128,6 +136,7 @@ def getTZ(request):
|
|
|
elif len(tz) == 8:
|
|
|
gmtz = tz.replace('UTC-', 'GMT-0').replace('UTC+', 'GMT+0')
|
|
|
info['gmt_offset'] = gmtz
|
|
|
+ redisObject.set_data(key=ip, val=json.dumps(info), expire=3600)
|
|
|
except Exception as e:
|
|
|
pass
|
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': info})
|