|
@@ -108,6 +108,10 @@ class AiView(View):
|
|
|
return self.do_ai_identification(request_dict, response)
|
|
|
elif operation == 'queryInfo': # 查询消息列表
|
|
|
return self.queryInfo(userID, request_dict, response)
|
|
|
+ elif operation == 'readInfo': # 消息已读
|
|
|
+ return self.readInfo(userID, request_dict, response)
|
|
|
+ elif operation == 'deleteInfo': # 删除消息
|
|
|
+ return self.deleteInfo(userID, request_dict, response)
|
|
|
else:
|
|
|
return response.json(414)
|
|
|
|
|
@@ -816,3 +820,49 @@ class AiView(View):
|
|
|
p['uid_type'] = ''
|
|
|
res.append(p)
|
|
|
return response.json(0, {'datas': res, 'count': count})
|
|
|
+
|
|
|
+ def readInfo(self, userID, request_dict, response):
|
|
|
+ is_update_all = request_dict.get('is_update_all', 0)
|
|
|
+
|
|
|
+ try:
|
|
|
+ if int(is_update_all) == 1: # 全部已读
|
|
|
+ is_update = Ai_Push_Info.objects.filter(userID_id=userID).update(status=1)
|
|
|
+ return response.json(0, {'update_count': is_update})
|
|
|
+ else:
|
|
|
+ id_list = request_dict.getlist('id[]', None)
|
|
|
+ if not id_list or len(id_list) < 1: # 单个已读
|
|
|
+ id_list = request_dict.getlist('id', None)
|
|
|
+ param_flag = CommonService.get_param_flag(data=[id_list])
|
|
|
+ if not param_flag:
|
|
|
+ return response.json(444)
|
|
|
+ count = 0
|
|
|
+ for id in id_list:
|
|
|
+ ai_push_qs = Ai_Push_Info.objects.filter(id=int(id))
|
|
|
+ if ai_push_qs.exists():
|
|
|
+ own_dev = ModelService.check_own_device(userID, ai_push_qs[0].devUid)
|
|
|
+ if own_dev:
|
|
|
+ count += 1
|
|
|
+ ai_push_qs.update(status=1)
|
|
|
+ return response.json(0, {'update_success': count})
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|
|
|
+
|
|
|
+ def deleteInfo(self, userID, request_dict, response):
|
|
|
+ id_list = request_dict.getlist('id[]', None)
|
|
|
+ if not id_list or len(id_list) < 1: # 单个删除
|
|
|
+ id_list = request_dict.getlist('id', None)
|
|
|
+ try:
|
|
|
+ param_flag = CommonService.get_param_flag(data=[id_list])
|
|
|
+ if not param_flag:
|
|
|
+ return response.json(444)
|
|
|
+ for id in id_list:
|
|
|
+ ai_push_qs = Ai_Push_Info.objects.filter(id=id)
|
|
|
+ if ai_push_qs.exists():
|
|
|
+ own_dev = ModelService.check_own_device(userID, ai_push_qs[0].devUid)
|
|
|
+ if own_dev:
|
|
|
+ ai_push_qs.delete()
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|