|
@@ -8,6 +8,7 @@ import oss2
|
|
|
from django.db import transaction
|
|
|
from django.db.models import Q, F
|
|
|
from django.views.generic.base import View
|
|
|
+from django.forms.models import model_to_dict
|
|
|
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, \
|
|
|
AWS_SES_ACCESS_REGION, UNUSED_SERIAL_REDIS_LIST
|
|
@@ -48,6 +49,8 @@ class DeviceManagement(View):
|
|
|
return self.get_device_icon(request_dict, response)
|
|
|
elif operation == 'addAppDeviceType': # 添加app设备类型数据并上传图标
|
|
|
return self.add_app_device_type(request_dict, response, request)
|
|
|
+ elif operation == 'getUidPush': # 查询推送信息
|
|
|
+ return self.get_uid_push(request_dict, response)
|
|
|
else:
|
|
|
tko = TokenObject(
|
|
|
request.META.get('HTTP_AUTHORIZATION'),
|
|
@@ -766,3 +769,41 @@ class DeviceManagement(View):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+ def get_uid_push(self, request_dict, response):
|
|
|
+ """
|
|
|
+ 查询设备信息图标
|
|
|
+ @param request_dict: 请求参数
|
|
|
+ @request_dict id: id
|
|
|
+ @param response: 响应对象
|
|
|
+ @return:
|
|
|
+ """
|
|
|
+ uid = request_dict.get('UID', None)
|
|
|
+ if not uid:
|
|
|
+ return response.json(444)
|
|
|
+ try:
|
|
|
+ uid_set_qs = UidSetModel.objects.get(uid=uid)
|
|
|
+ data = model_to_dict(uid_set_qs)
|
|
|
+ # uid_set查uid_push
|
|
|
+ uid_pushes_qs = UidPushModel.objects.filter(uid_set_id=uid_set_qs.id).select_related('userID')
|
|
|
+ uid_push_data = []
|
|
|
+ # 保存uid_pushes_qs列表
|
|
|
+ for item in uid_pushes_qs:
|
|
|
+ item_dict = model_to_dict(item)
|
|
|
+ # 添加 username 字段
|
|
|
+ item_dict['username'] = item.userID.username if item.userID else None
|
|
|
+ uid_push_data.append(item_dict)
|
|
|
+ data["uid_push"] = uid_push_data
|
|
|
+ return response.json(0, data)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|