|
@@ -24,32 +24,27 @@ def addNewUserEquipment(userID, deviceContent, response):
|
|
|
if dValid:
|
|
|
return response.json(174)
|
|
|
else:
|
|
|
- # 判断是否有同样昵称存在
|
|
|
- # if 'NickName' in deviceData:
|
|
|
- # nValid = Device_Info.objects.filter(userID=userID, NickName=deviceData['NickName'])
|
|
|
- # if nValid.exists():
|
|
|
- # return response.json(179)
|
|
|
UID = deviceData.get('UID', '')
|
|
|
re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
|
if re_uid.match(UID):
|
|
|
- # is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
|
- is_bind = ''
|
|
|
+ is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
|
+ # is_bind = ''
|
|
|
# 判断是否有已绑定用户
|
|
|
if is_bind:
|
|
|
# return response.json(175)
|
|
|
# 判断用户密码是否正确
|
|
|
- # dev_user = deviceData.get('View_Account', '')
|
|
|
- # dev_pass = deviceData.get('View_Password', '')
|
|
|
- # if is_bind[0].View_Account == dev_user and is_bind[0].View_Password == dev_pass:
|
|
|
- deviceData['NickName'] = is_bind[0].NickName
|
|
|
- if 'isShare' in deviceData:
|
|
|
- deviceData['isShare'] = True
|
|
|
- userDevice = Device_Info(id=CommonService.getUserID(getUser=False),
|
|
|
- primaryUserID=is_bind[0].userID_id, userID_id=userID,
|
|
|
- **deviceData)
|
|
|
- userDevice.save()
|
|
|
- # else:
|
|
|
- # return response.json(111)
|
|
|
+ dev_user = deviceData.get('View_Account', '')
|
|
|
+ dev_pass = deviceData.get('View_Password', '')
|
|
|
+ if is_bind[0].View_Account == dev_user and is_bind[0].View_Password == dev_pass:
|
|
|
+ deviceData['NickName'] = is_bind[0].NickName
|
|
|
+ if 'isShare' in deviceData:
|
|
|
+ deviceData['isShare'] = True
|
|
|
+ userDevice = Device_Info(id=CommonService.getUserID(getUser=False),
|
|
|
+ primaryUserID=is_bind[0].userID_id, userID_id=userID,
|
|
|
+ **deviceData)
|
|
|
+ userDevice.save()
|
|
|
+ else:
|
|
|
+ return response.json(111)
|
|
|
else:
|
|
|
userDevice = Device_Info(id=CommonService.getUserID(getUser=False), userID_id=userID,
|
|
|
**deviceData)
|
|
@@ -106,7 +101,6 @@ def showAllUserEquipment(userID, response):
|
|
|
if not userValid.exists():
|
|
|
return response.json(104)
|
|
|
own_perm = ModelService.check_permission(userID=userID, permID=30)
|
|
|
- # if userValid[0].is_superuser != 100 and userValid[0].is_superuser != 1:
|
|
|
if own_perm is not True:
|
|
|
return response.json(404)
|
|
|
qs = Device_Info.objects.all()
|
|
@@ -161,16 +155,9 @@ def findEquipmentInfo(content, type, fieldDict):
|
|
|
return send_dict
|
|
|
|
|
|
|
|
|
+# 查询用户设备
|
|
|
@csrf_exempt
|
|
|
-def queryUserEquipmentInterface(request, *callback_args,
|
|
|
- **callback_kwargs):
|
|
|
- '''
|
|
|
- 查询用户设备
|
|
|
- :param request:
|
|
|
- :param callback_args:
|
|
|
- :param callback_kwargs:
|
|
|
- :return:
|
|
|
- '''
|
|
|
+def queryUserEquipmentInterface(request):
|
|
|
response = ResponseObject()
|
|
|
if request.method == 'POST':
|
|
|
request.encoding = 'utf-8'
|
|
@@ -188,8 +175,8 @@ def queryUserEquipmentInterface(request, *callback_args,
|
|
|
userID = tko.userID
|
|
|
if not userID:
|
|
|
return response.json(104)
|
|
|
- deviceValid = Device_Info.objects.filter(userID_id=userID)
|
|
|
- res = CommonService.qs_to_dict(deviceValid)
|
|
|
+ dvqs = Device_Info.objects.filter(userID_id=userID)
|
|
|
+ res = CommonService.qs_to_dict(dvqs)
|
|
|
datas = res['datas']
|
|
|
uid_list = []
|
|
|
for q in datas:
|
|
@@ -204,6 +191,7 @@ def queryUserEquipmentInterface(request, *callback_args,
|
|
|
for dm in ubql:
|
|
|
if p['fields']['UID'] == dm['uid']:
|
|
|
p['fields']['vod'].append(dm)
|
|
|
+ p['fields']['master'] = ModelService.get_user_name(p['fields']['primaryUserID'])
|
|
|
res.append(p)
|
|
|
# print(res)
|
|
|
return response.json(0, {'datas': res})
|
|
@@ -328,31 +316,24 @@ def modifyUserEquipmentInterface(request, *callback_args,
|
|
|
|
|
|
@csrf_exempt
|
|
|
def showAllUserEquipmentInterface(request, *callback_args, **callback_kwargs):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
if request.method == 'POST':
|
|
|
- request.encoding = 'utf-8'
|
|
|
fieldDict = request.POST
|
|
|
if request.method == 'GET':
|
|
|
- request.encoding = 'utf-8'
|
|
|
fieldDict = request.GET
|
|
|
token = request.POST.get('token', None)
|
|
|
type = request.POST.get('type', None)
|
|
|
response = ResponseObject()
|
|
|
- if token != None:
|
|
|
- tko = TokenObject(token)
|
|
|
- response.lang = tko.lang
|
|
|
- if tko.code == 0:
|
|
|
- userID = tko.userID
|
|
|
- if userID:
|
|
|
- if type == 'PC':
|
|
|
- return showAllUserEquipmentPC(userID, fieldDict, response)
|
|
|
- else:
|
|
|
- return showAllUserEquipment(userID, response)
|
|
|
- else:
|
|
|
- return response.json(309)
|
|
|
- else:
|
|
|
- return response.json(tko.code)
|
|
|
- else:
|
|
|
- return response.json(800)
|
|
|
+ tko = TokenObject(token)
|
|
|
+ response.lang = tko.lang
|
|
|
+ if tko.code != 0:
|
|
|
+ return response.json(tko.code)
|
|
|
+ userID = tko.userID
|
|
|
+ if not userID:
|
|
|
+ return response.json(104)
|
|
|
+ if type == 'PC':
|
|
|
+ return showAllUserEquipmentPC(userID, fieldDict, response)
|
|
|
+ return showAllUserEquipment(userID, response)
|
|
|
|
|
|
|
|
|
@csrf_exempt
|