|
@@ -92,6 +92,8 @@ class UidSetView(View):
|
|
return self.do_set_voice(userID, request_dict, response)
|
|
return self.do_set_voice(userID, request_dict, response)
|
|
elif operation == 'vod_reset':
|
|
elif operation == 'vod_reset':
|
|
return self.vod_reset(request_dict, response)
|
|
return self.vod_reset(request_dict, response)
|
|
|
|
+ elif operation == 'primary_user_reset':
|
|
|
|
+ return self.primary_user_reset(request_dict, response)
|
|
# elif operation == 'test':
|
|
# elif operation == 'test':
|
|
# return self.do_test(response)
|
|
# return self.do_test(response)
|
|
else:
|
|
else:
|
|
@@ -380,7 +382,7 @@ class UidSetView(View):
|
|
token = request_dict.get('token', None)
|
|
token = request_dict.get('token', None)
|
|
print(channelContent)
|
|
print(channelContent)
|
|
if not channelContent or not uid or not channel:
|
|
if not channelContent or not uid or not channel:
|
|
- return response.json(444, 'content,uid, chan')
|
|
|
|
|
|
+ return response.json(444, 'content,uid, channel')
|
|
tko = TokenObject(token)
|
|
tko = TokenObject(token)
|
|
response.lang = tko.lang
|
|
response.lang = tko.lang
|
|
if tko.code != 0:
|
|
if tko.code != 0:
|
|
@@ -393,12 +395,10 @@ class UidSetView(View):
|
|
if channel < 1:
|
|
if channel < 1:
|
|
return response.json(444, 'channel')
|
|
return response.json(444, 'channel')
|
|
try:
|
|
try:
|
|
- # redisObj = RedisObject(db=8)
|
|
|
|
- # redisObj.del_data(key='uid_qs_' + userID)
|
|
|
|
deviceData = json.loads(channelContent)
|
|
deviceData = json.loads(channelContent)
|
|
uid_channel_set_qs = UidChannelSetModel.objects.filter(uid__uid=uid, channel=channel)
|
|
uid_channel_set_qs = UidChannelSetModel.objects.filter(uid__uid=uid, channel=channel)
|
|
|
|
+ uidObject = UidSetModel.objects.filter(uid=uid)
|
|
if not uid_channel_set_qs.exists():
|
|
if not uid_channel_set_qs.exists():
|
|
- uidObject = UidSetModel.objects.filter(uid=uid)
|
|
|
|
ucs = {
|
|
ucs = {
|
|
'channel': channel,
|
|
'channel': channel,
|
|
'uid': uidObject[0]
|
|
'uid': uidObject[0]
|
|
@@ -410,6 +410,13 @@ class UidSetView(View):
|
|
else:
|
|
else:
|
|
uid_channel_set_qs.update(**deviceData)
|
|
uid_channel_set_qs.update(**deviceData)
|
|
|
|
|
|
|
|
+ if uidObject[0].is_alexa == 1 and 'channel_name' in deviceData.keys():
|
|
|
|
+ # 请求Alexa服务器更新事件网关
|
|
|
|
+ data_list = [{'userID': userID, 'UID': uid, 'uid_nick': deviceData['channel_name'], 'password': ''}]
|
|
|
|
+ data_list = json.dumps(data_list)
|
|
|
|
+ data = {'data_list': data_list}
|
|
|
|
+ url = 'https://www.zositech.xyz/deviceStatus/addOrUpdateV2'
|
|
|
|
+ requests.post(url, data=data, timeout=2)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(177, repr(e))
|
|
return response.json(177, repr(e))
|
|
else:
|
|
else:
|
|
@@ -508,6 +515,17 @@ class UidSetView(View):
|
|
else:
|
|
else:
|
|
return response.json(0)
|
|
return response.json(0)
|
|
|
|
|
|
|
|
+ # 重置设备主用户
|
|
|
|
+ def primary_user_reset(self, request_dict, response):
|
|
|
|
+ uid = request_dict.get('uid', None)
|
|
|
|
+ if not uid:
|
|
|
|
+ return response.json(404)
|
|
|
|
+ try:
|
|
|
|
+ Device_Info.objects.filter(UID=uid).update(vodPrimaryUserID='', vodPrimaryMaster='')
|
|
|
|
+ return response.json(0)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ return response.json(500, repr(e))
|
|
|
|
+
|
|
# def do_test(self, response):
|
|
# def do_test(self, response):
|
|
# di_qs = Device_Info.objects.values('Type').annotate(c=Count('UID', distinct=True)).order_by()
|
|
# di_qs = Device_Info.objects.values('Type').annotate(c=Count('UID', distinct=True)).order_by()
|
|
# for di in di_qs:
|
|
# for di in di_qs:
|