|
@@ -1,15 +1,12 @@
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
|
|
-from django.core import serializers
|
|
|
import traceback
|
|
|
from Service.ModelService import ModelService
|
|
|
-from Model.models import Device_User, Device_Info
|
|
|
+from Model.models import Device_User, Device_Info,Device_Meal
|
|
|
from Service.CommonService import CommonService
|
|
|
import simplejson as json
|
|
|
from Object.TokenObject import TokenObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
import re
|
|
|
-from Ansjer.config import UID_TOKEN_KEY
|
|
|
-import jwt
|
|
|
|
|
|
|
|
|
def addNewUserEquipment(userID, deviceContent, response):
|
|
@@ -214,35 +211,35 @@ def queryUserEquipmentInterface(request, *callback_args,
|
|
|
token = request.GET.get('token', None)
|
|
|
else:
|
|
|
return response.json(801)
|
|
|
- if token is not None:
|
|
|
- tko = TokenObject(token)
|
|
|
- tko.valid()
|
|
|
- response.lang = tko.lang
|
|
|
- if tko.code == 0:
|
|
|
- userID = tko.userID
|
|
|
- if userID is not None:
|
|
|
- try:
|
|
|
- deviceValid = Device_Info.objects.filter(userID_id=userID)
|
|
|
- except Exception as e:
|
|
|
- errorInfo = traceback.format_exc()
|
|
|
- print('查询数据库错误: %s' % errorInfo)
|
|
|
- return response.json(500, repr(e))
|
|
|
- else:
|
|
|
- if deviceValid.exists():
|
|
|
- res = CommonService.qs_to_dict(deviceValid)
|
|
|
- return response.json(0, res)
|
|
|
- else:
|
|
|
- UserValid = Device_User.objects.filter(userID=userID)
|
|
|
- if UserValid.exists():
|
|
|
- return response.json(172)
|
|
|
- else:
|
|
|
- return response.json(113)
|
|
|
- else:
|
|
|
- return response.json(309)
|
|
|
- else:
|
|
|
- return response.json(tko.code)
|
|
|
+ tko = TokenObject(token)
|
|
|
+ tko.valid()
|
|
|
+ response.lang = tko.lang
|
|
|
+ if tko.code != 0:
|
|
|
+ return response.json(tko.code)
|
|
|
+ userID = tko.userID
|
|
|
+ if userID is not None:
|
|
|
+ deviceValid = Device_Info.objects.filter(userID_id=userID)
|
|
|
+ # print(deviceValid)
|
|
|
+ res = CommonService.qs_to_dict(deviceValid)
|
|
|
+ datas = res['datas']
|
|
|
+ uid_list = []
|
|
|
+ for q in datas:
|
|
|
+ uid_list.append(q['fields']['UID'])
|
|
|
+ dmqs = Device_Meal.objects.filter(uid__in=uid_list).\
|
|
|
+ values('rank', 'status', 'channel', 'end_time', 'rank__title','uid')
|
|
|
+ dmlt = CommonService.qs_to_list(dmqs)
|
|
|
+ # print(uid_list)
|
|
|
+ res = []
|
|
|
+ for p in datas:
|
|
|
+ p['fields']['vod'] = []
|
|
|
+ for dm in dmlt:
|
|
|
+ if p['fields']['UID'] == dm['uid']:
|
|
|
+ p['fields']['vod'].append(dm)
|
|
|
+ res.append(p)
|
|
|
+ print(res)
|
|
|
+ return response.json(0, {'datas':res})
|
|
|
else:
|
|
|
- return response.json(800)
|
|
|
+ return response.json(309)
|
|
|
|
|
|
|
|
|
@csrf_exempt
|