|
@@ -50,7 +50,7 @@ def generate_utk(request):
|
|
|
return response.json(444,'username password')
|
|
|
|
|
|
|
|
|
-# 设备影子更新
|
|
|
+
|
|
|
def update_device_shadow(request):
|
|
|
request.encoding = 'utf-8'
|
|
|
response = ResponseObject()
|
|
@@ -82,7 +82,6 @@ def update_device_shadow(request):
|
|
|
push_status = request_dict.get('push_status', None)
|
|
|
pwd = request_dict.get('pwd', None)
|
|
|
resetTime = request_dict.get('resetTime', None)
|
|
|
- is_alexa = request_dict.get('is_alexa', None)
|
|
|
|
|
|
us_qs = UidSetModel.objects.filter(uid=uid)
|
|
|
# 更新
|
|
@@ -91,39 +90,64 @@ def update_device_shadow(request):
|
|
|
print('-------')
|
|
|
print(resetTime)
|
|
|
print('-------')
|
|
|
- qs_dict = {
|
|
|
- 'updTime': nowTime,
|
|
|
- 'ip': ip
|
|
|
- }
|
|
|
- if channel:
|
|
|
- qs_dict['channel'] = channel
|
|
|
- if p2p_region:
|
|
|
- qs_dict['p2p_region'] = p2p_region
|
|
|
- if ucode:
|
|
|
- qs_dict['ucode'] = ucode
|
|
|
- if version:
|
|
|
- qs_dict['version'] = version
|
|
|
- if tz:
|
|
|
- qs_dict['tz'] = tz
|
|
|
- if video_code:
|
|
|
- qs_dict['video_code'] = video_code
|
|
|
- if cloud_vod:
|
|
|
- qs_dict['cloud_vod'] = cloud_vod
|
|
|
- if push_status:
|
|
|
- qs_dict['detect_status'] = push_status
|
|
|
- if pwd:
|
|
|
- qs_dict['pwd'] = pwd
|
|
|
- if is_alexa:
|
|
|
- qs_dict['is_alexa'] = is_alexa
|
|
|
+
|
|
|
if us_qs.exists():
|
|
|
- us_qs.update(**qs_dict)
|
|
|
+ update_dict = {
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'ip': ip
|
|
|
+ }
|
|
|
+ if channel:
|
|
|
+ update_dict['channel'] = channel
|
|
|
+ if p2p_region:
|
|
|
+ update_dict['p2p_region'] = p2p_region
|
|
|
+ if ucode:
|
|
|
+ update_dict['ucode'] = ucode
|
|
|
+ if version:
|
|
|
+ update_dict['version'] = version
|
|
|
+ if tz:
|
|
|
+ update_dict['tz'] = tz
|
|
|
+ if video_code:
|
|
|
+ update_dict['video'] = video_code
|
|
|
+ if cloud_vod:
|
|
|
+ update_dict['cloud_vod'] = cloud_vod
|
|
|
+ if push_status:
|
|
|
+ update_dict['detect_status'] = push_status
|
|
|
+ if pwd:
|
|
|
+ update_dict['pwd'] = pwd
|
|
|
+ us_qs.update(**update_dict)
|
|
|
# 如果推送状态开启,返回推送url
|
|
|
+ data = {}
|
|
|
+
|
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|
|
|
# 新增
|
|
|
else:
|
|
|
- qs_dict['uid'] = uid
|
|
|
- qs_dict['addTime'] = nowTime
|
|
|
- UidSetModel.objects.create(**qs_dict)
|
|
|
+ create_dict = {
|
|
|
+ 'uid': uid,
|
|
|
+ 'addTime': nowTime,
|
|
|
+ 'updTime': nowTime,
|
|
|
+ 'ip': ip
|
|
|
+ }
|
|
|
+ if channel:
|
|
|
+ create_dict['channel'] = channel
|
|
|
+ if p2p_region:
|
|
|
+ create_dict['p2p_region'] = p2p_region
|
|
|
+ if ucode:
|
|
|
+ create_dict['ucode'] = ucode
|
|
|
+ if version:
|
|
|
+ create_dict['version'] = version
|
|
|
+ if tz:
|
|
|
+ create_dict['tz'] = tz
|
|
|
+ if video_code:
|
|
|
+ create_dict['video_code'] = video_code
|
|
|
+ if cloud_vod:
|
|
|
+ create_dict['cloud_vod'] = cloud_vod
|
|
|
+ if push_status:
|
|
|
+ create_dict['detect_status'] = push_status
|
|
|
+ if pwd:
|
|
|
+ create_dict['pwd'] = pwd
|
|
|
+ if resetTime:
|
|
|
+ create_dict['resetTime'] = resetTime
|
|
|
+ UidSetModel.objects.create(**create_dict)
|
|
|
# 如果推送状态开启,返回推送url
|
|
|
return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
|
|
|
else:
|