|
@@ -132,18 +132,12 @@ class EquipmentManagerV3(View):
|
|
redisObj = RedisObject(db=8)
|
|
redisObj = RedisObject(db=8)
|
|
redis_value = redisObj.get_data(key='uid_qs_'+userID)
|
|
redis_value = redisObj.get_data(key='uid_qs_'+userID)
|
|
if redis_value == False:
|
|
if redis_value == False:
|
|
- print('缓存不存在就开始添加到缓存')
|
|
|
|
|
|
+ # print('缓存不存在就开始添加到缓存')
|
|
userID = tko.userID
|
|
userID = tko.userID
|
|
dvqs = Device_Info.objects.filter(userID_id=userID)
|
|
dvqs = Device_Info.objects.filter(userID_id=userID)
|
|
# # 过滤已重置的设备
|
|
# # 过滤已重置的设备
|
|
dvqs = dvqs.filter(~Q(isExist=2))
|
|
dvqs = dvqs.filter(~Q(isExist=2))
|
|
-
|
|
|
|
- if NickName:
|
|
|
|
- dvqs = dvqs.filter(NickName__icontains=NickName)
|
|
|
|
- if uid:
|
|
|
|
- dvqs = dvqs.filter(UID=uid)
|
|
|
|
- dvql = dvqs[(page - 1) * line:page * line]. \
|
|
|
|
- values('id', 'userID', 'NickName', 'UID', 'View_Account',
|
|
|
|
|
|
+ dvql = dvqs.values('id', 'userID', 'NickName', 'UID', 'View_Account',
|
|
'View_Password', 'ChannelIndex', 'Type', 'isShare',
|
|
'View_Password', 'ChannelIndex', 'Type', 'isShare',
|
|
'primaryUserID', 'primaryMaster', 'data_joined',
|
|
'primaryUserID', 'primaryMaster', 'data_joined',
|
|
'version',
|
|
'version',
|
|
@@ -191,19 +185,40 @@ class EquipmentManagerV3(View):
|
|
data.append(p)
|
|
data.append(p)
|
|
# 缓存时间为一个钟
|
|
# 缓存时间为一个钟
|
|
redisObj.set_data(key='uid_qs_'+userID, val=data, expire=3600)
|
|
redisObj.set_data(key='uid_qs_'+userID, val=data, expire=3600)
|
|
- return response.json(0, data)
|
|
|
|
|
|
+ print('分页')
|
|
|
|
+ items=[]
|
|
|
|
+ for index, item in enumerate(data):
|
|
|
|
+ if (page - 1) * line <= index:
|
|
|
|
+ if index < page * line:
|
|
|
|
+ items.append(item)
|
|
|
|
+ return response.json(0, items)
|
|
else:
|
|
else:
|
|
- print('去缓存找数据')
|
|
|
|
|
|
+ # print('去缓存找数据')
|
|
redis_value = redis_value.replace("'", '"')
|
|
redis_value = redis_value.replace("'", '"')
|
|
redis_value = redis_value.replace("True", 'true')
|
|
redis_value = redis_value.replace("True", 'true')
|
|
redis_value = redis_value.replace("False", 'false')
|
|
redis_value = redis_value.replace("False", 'false')
|
|
- # 返回固定值
|
|
|
|
- return response.json(0, json.loads(redis_value))
|
|
|
|
|
|
+ redis_value = json.loads(redis_value)
|
|
|
|
+ if NickName:
|
|
|
|
+ # print('NickName搜索缓存')
|
|
|
|
+ for index, item in enumerate(redis_value):
|
|
|
|
+ if NickName ==item['NickName']:
|
|
|
|
+ return response.json(0, item)
|
|
|
|
+ if uid:
|
|
|
|
+ # print('uid搜索缓存')
|
|
|
|
+ for index, item in enumerate(redis_value):
|
|
|
|
+ if uid == item['UID']:
|
|
|
|
+ return response.json(0, item)
|
|
|
|
+ items = []
|
|
|
|
+ # print('缓存分页')
|
|
|
|
+ for index, item in enumerate(redis_value):
|
|
|
|
+ if (page - 1) * line <= index:
|
|
|
|
+ if index < page * line:
|
|
|
|
+ items.append(item)
|
|
|
|
+ return response.json(0, items)
|
|
else:
|
|
else:
|
|
return response.json(tko.code)
|
|
return response.json(tko.code)
|
|
|
|
|
|
# 新查询设备字段
|
|
# 新查询设备字段
|
|
-
|
|
|
|
def do_query_reset(self, userID, request_dict, response):
|
|
def do_query_reset(self, userID, request_dict, response):
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, isExist=2)
|
|
dvqs = Device_Info.objects.filter(userID_id=userID, isExist=2)
|
|
dvql = dvqs.values\
|
|
dvql = dvqs.values\
|