|
@@ -1,7 +1,7 @@
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
import traceback
|
|
import traceback
|
|
from Service.ModelService import ModelService
|
|
from Service.ModelService import ModelService
|
|
-from Model.models import Device_User, Device_Info,Device_Meal,UID_Bucket
|
|
|
|
|
|
+from Model.models import Device_User, Device_Info, Device_Meal, UID_Bucket
|
|
from Service.CommonService import CommonService
|
|
from Service.CommonService import CommonService
|
|
import simplejson as json
|
|
import simplejson as json
|
|
from Object.TokenObject import TokenObject
|
|
from Object.TokenObject import TokenObject
|
|
@@ -33,7 +33,7 @@ def addNewUserEquipment(userID, deviceContent, response):
|
|
re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
re_uid = re.compile(r'^[A-Za-z0-9]{20}$')
|
|
if re_uid.match(UID):
|
|
if re_uid.match(UID):
|
|
# is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
# is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
|
|
- is_bind=''
|
|
|
|
|
|
+ is_bind = ''
|
|
# 判断是否有已绑定用户
|
|
# 判断是否有已绑定用户
|
|
if is_bind:
|
|
if is_bind:
|
|
# return response.json(175)
|
|
# return response.json(175)
|
|
@@ -106,7 +106,7 @@ def modifyUserEquipment(userID, deviceContent, id, response):
|
|
if deviceValid:
|
|
if deviceValid:
|
|
deviceData = json.loads(deviceContent)
|
|
deviceData = json.loads(deviceContent)
|
|
try:
|
|
try:
|
|
- userDevice = Device_Info.objects.filter(userID_id=userID, id=id).update(**deviceData)
|
|
|
|
|
|
+ Device_Info.objects.filter(userID_id=userID, id=id).update(**deviceData)
|
|
except Exception as e:
|
|
except Exception as e:
|
|
errorInfo = traceback.format_exc()
|
|
errorInfo = traceback.format_exc()
|
|
print('修改设备信息错误: %s ' % errorInfo)
|
|
print('修改设备信息错误: %s ' % errorInfo)
|
|
@@ -130,18 +130,17 @@ def showAllUserEquipment(userID, response):
|
|
errorInfo = traceback.format_exc()
|
|
errorInfo = traceback.format_exc()
|
|
print('查询数据库错误: %s' % errorInfo)
|
|
print('查询数据库错误: %s' % errorInfo)
|
|
return response.json(500, repr(e))
|
|
return response.json(500, repr(e))
|
|
-
|
|
|
|
else:
|
|
else:
|
|
- if userValid.exists():
|
|
|
|
- # own_permission = ModelService.check_permission(userID=userID,permID=30)
|
|
|
|
- if userValid[0].is_superuser != 100 and userValid[0].is_superuser != 1:
|
|
|
|
- return response.json(612)
|
|
|
|
- else:
|
|
|
|
- qs = Device_Info.objects.all()
|
|
|
|
- res = CommonService.qs_to_dict(qs)
|
|
|
|
- return response.json(0, res)
|
|
|
|
- else:
|
|
|
|
|
|
+ if not userValid.exists():
|
|
return response.json(113)
|
|
return response.json(113)
|
|
|
|
+ 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(612)
|
|
|
|
+ qs = Device_Info.objects.all()
|
|
|
|
+ res = CommonService.qs_to_dict(qs)
|
|
|
|
+ return response.json(0, res)
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
def showAllUserEquipmentPC(userID, fieldDict, response):
|
|
def showAllUserEquipmentPC(userID, fieldDict, response):
|
|
@@ -152,21 +151,19 @@ def showAllUserEquipmentPC(userID, fieldDict, response):
|
|
print('查询数据库错误: %s' % errorInfo)
|
|
print('查询数据库错误: %s' % errorInfo)
|
|
return response.json(500, repr(e))
|
|
return response.json(500, repr(e))
|
|
else:
|
|
else:
|
|
- if user_valid:
|
|
|
|
- own_permission = ModelService.check_permission(userID=userID, permID=30)
|
|
|
|
- if own_permission:
|
|
|
|
- page = int(fieldDict['page'])
|
|
|
|
- line = int(fieldDict['line'])
|
|
|
|
- device_info_query_set = Device_Info.objects.all()
|
|
|
|
- device_info_count = device_info_query_set.count()
|
|
|
|
- device_info_res = device_info_query_set[(page - 1) * line:page * line]
|
|
|
|
- sqlDict = CommonService.qs_to_dict(query_set=device_info_res)
|
|
|
|
- sqlDict['count'] = device_info_count
|
|
|
|
- return response.json(0, sqlDict)
|
|
|
|
- else:
|
|
|
|
- return response.json(612)
|
|
|
|
- else:
|
|
|
|
|
|
+ if not user_valid:
|
|
return response.json(113)
|
|
return response.json(113)
|
|
|
|
+ own_permission = ModelService.check_permission(userID=userID, permID=30)
|
|
|
|
+ if not own_permission:
|
|
|
|
+ return response.json(612)
|
|
|
|
+ page = int(fieldDict['page'])
|
|
|
|
+ line = int(fieldDict['line'])
|
|
|
|
+ device_info_query_set = Device_Info.objects.all()
|
|
|
|
+ device_info_count = device_info_query_set.count()
|
|
|
|
+ device_info_res = device_info_query_set[(page - 1) * line:page * line]
|
|
|
|
+ sqlDict = CommonService.qs_to_dict(query_set=device_info_res)
|
|
|
|
+ sqlDict['count'] = device_info_count
|
|
|
|
+ return response.json(0, sqlDict)
|
|
|
|
|
|
|
|
|
|
def findEquipmentInfo(content, type, fieldDict):
|
|
def findEquipmentInfo(content, type, fieldDict):
|
|
@@ -258,7 +255,7 @@ def queryUserEquipmentInterface(request, *callback_args,
|
|
p['fields']['vod'].append(dm)
|
|
p['fields']['vod'].append(dm)
|
|
res.append(p)
|
|
res.append(p)
|
|
print(res)
|
|
print(res)
|
|
- return response.json(0, {'datas':res})
|
|
|
|
|
|
+ return response.json(0, {'datas': res})
|
|
else:
|
|
else:
|
|
return response.json(309)
|
|
return response.json(309)
|
|
|
|
|