|
@@ -61,8 +61,10 @@ class EquipmentManagerV3(View):
|
|
|
View_Password = self.decode_pwd(View_Password)
|
|
|
Type = request_dict.get('Type', None)
|
|
|
ChannelIndex = request_dict.get('ChannelIndex', None)
|
|
|
+
|
|
|
if all([UID, NickName, View_Account, Type, ChannelIndex]):
|
|
|
tko = TokenObject(token)
|
|
|
+
|
|
|
response.lang = tko.lang
|
|
|
if tko.code == 0:
|
|
|
userID = tko.userID
|
|
@@ -76,12 +78,10 @@ class EquipmentManagerV3(View):
|
|
|
else:
|
|
|
is_exist.delete()
|
|
|
if UID == '98UXAA8BRPA35VAL111A':
|
|
|
- file_path = '/'.join((BASE_DIR, 'static/add_device.log'))
|
|
|
- file = open(file_path, 'a+')
|
|
|
- file.write(CommonService.get_ip_address(request) + "; username:" + userID + "; time:" + time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()) + "; addV3")
|
|
|
- file.write('\n')
|
|
|
- file.flush()
|
|
|
- file.close()
|
|
|
+ asy = threading.Thread(target=ModelService.add_log,
|
|
|
+ args=(CommonService.get_ip_address(request), userID, 'addV3'))
|
|
|
+ asy.start()
|
|
|
+
|
|
|
# is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
|
# # 判断是否有已绑定用户
|
|
|
# if is_bind:
|
|
@@ -162,20 +162,14 @@ class EquipmentManagerV3(View):
|
|
|
print(e)
|
|
|
return response.json(177, repr(e))
|
|
|
else:
|
|
|
- # qs = Device_Info.objects.filter(userID_id=userID, id=id)
|
|
|
- qs = dev_info_qs
|
|
|
+ qs = Device_Info.objects.filter(userID_id=userID, id=id)
|
|
|
res = CommonService.qs_to_dict(qs)
|
|
|
if qs.exists():
|
|
|
uid = qs[0].UID
|
|
|
if uid == '98UXAA8BRPA35VAL111A':
|
|
|
- file_path = '/'.join((BASE_DIR, 'static/add_device.log'))
|
|
|
- file = open(file_path, 'a+')
|
|
|
- file.write(
|
|
|
- CommonService.get_ip_address(request) + "; username:" + userID + "; time:" + time.strftime(
|
|
|
- "%Y-%m-%d %H:%M:%S", time.localtime()) + "; modifyV3")
|
|
|
- file.write('\n')
|
|
|
- file.flush()
|
|
|
- file.close()
|
|
|
+ asy = threading.Thread(target=ModelService.add_log,
|
|
|
+ args=(CommonService.get_ip_address(request), userID, 'modifyV3'))
|
|
|
+ asy.start()
|
|
|
|
|
|
nickname = qs[0].NickName
|
|
|
# 增加设备影子信息修改昵称 start
|
|
@@ -197,6 +191,10 @@ class EquipmentManagerV3(View):
|
|
|
UidSetModel.objects.create(**uid_set_create_dict)
|
|
|
di_qs = Device_Info.objects.filter(UID=uid)
|
|
|
di_qs.update(NickName=nickname)
|
|
|
+ if deviceData is not None and deviceData.__contains__('NickName') and us_qs[0].is_alexa == 1:
|
|
|
+
|
|
|
+ asy = threading.Thread(target=ModelService.notify_alexa_add, args=(uid, userID, nickname))
|
|
|
+ asy.start()
|
|
|
# redisObj = RedisObject(db=8)
|
|
|
# redisObj.del_data(key='uid_qs_' + userID)
|
|
|
return response.json(0, res)
|
|
@@ -350,7 +348,7 @@ class EquipmentManagerV3(View):
|
|
|
for index, item in enumerate(result):
|
|
|
if uid == item['UID']:
|
|
|
# 加密
|
|
|
- item['View_Password'] = self.encrypt_pwd(item['View_Password'])
|
|
|
+ item['View_Password'] = self.encrypt_pwd(item['View_Password'])
|
|
|
data.append(item)
|
|
|
return response.json(0, data)
|
|
|
items = []
|
|
@@ -402,6 +400,4 @@ class EquipmentManagerV3(View):
|
|
|
password = password.decode('utf-8')
|
|
|
# 去前3位,后3位
|
|
|
password = password[3:-3]
|
|
|
- return password
|
|
|
-
|
|
|
-
|
|
|
+ return password
|