|
@@ -6,6 +6,7 @@ import time
|
|
|
|
|
|
from django.views import View
|
|
|
|
|
|
+from Object.RedisObject import RedisObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Model.models import AbnormalEvent
|
|
|
|
|
@@ -37,6 +38,17 @@ class ReportView(View):
|
|
|
if not all([uid, device_type, version, event_list]):
|
|
|
return response.json(444)
|
|
|
|
|
|
+ # 同一设备限制十分钟之内不能重复请求
|
|
|
+ redis_obj = RedisObject()
|
|
|
+ key = 'report_abnormal_event_{}'.format(uid)
|
|
|
+ ttl = redis_obj.get_ttl(key)
|
|
|
+ if ttl > 0:
|
|
|
+ res = {
|
|
|
+ 'limit_time': ttl
|
|
|
+ }
|
|
|
+ return response.json(10, res)
|
|
|
+ redis_obj.set_data(key=key, val=1, expire=600)
|
|
|
+
|
|
|
try:
|
|
|
device_type = int(device_type)
|
|
|
now_time = int(time.time())
|