瀏覽代碼

用户反馈信息导出和收藏功能(注释)

guanhailong 2 年之前
父節點
當前提交
650871dd88
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      AdminController/UserManageController.py

+ 8 - 6
AdminController/UserManageController.py

@@ -304,8 +304,6 @@ class UserManagement(View):
             return self.replyFeedBack(request_dict, response)
         elif operation == 'sendSysMsgToUser':
             return self.sendSysMsgToUser(request_dict, response)
-        elif operation == 'collectFeedBack':
-            return self.collectFeedBack(request_dict, response)
         else:
             tko = TokenObject(request.META.get('HTTP_AUTHORIZATION'), returntpye='pc')
             if tko.code != 0:
@@ -326,6 +324,8 @@ class UserManagement(View):
                 return self.deleteFeedBack(request_dict, response)
             elif operation == 'getSysMessageList':
                 return self.getSysMessageList(request_dict, response)
+            elif operation == 'collectFeedBack':
+                return self.collectFeedBack(request_dict, response)
             else:
                 return response.json(404)
 
@@ -474,7 +474,7 @@ class UserManagement(View):
         status = request_dict.get('status', 0)
         username = request_dict.get('username', None)
         collect_status = request_dict.get('collectStatus', 0)
-        fileType = request_dict.get('fileType', None)
+        fileType = request_dict.get('fileType', None)  # 导出参数
         pageNo = request_dict.get('pageNo', None)
         pageSize = request_dict.get('pageSize', None)
 
@@ -483,6 +483,7 @@ class UserManagement(View):
 
         page = int(pageNo)
         line = int(pageSize)
+        fileType = int(fileType)
         try:
             filter_data = {}
             if status or username or collect_status:
@@ -514,7 +515,7 @@ class UserManagement(View):
                 'score',
                 'collect_status'
             )
-            if fileType:
+            if fileType == 1:  # 判断是否导出
                 feed_backs = feed_backs
             else:
                 feed_backs = feed_backs[(page - 1) * line: page * line]
@@ -678,14 +679,15 @@ class UserManagement(View):
             return response.json(500, repr(e))
 
     def collectFeedBack(self, request_dict, response):
+        """收藏或取消收藏用户反馈信息"""
         feedBackID = request_dict.get('feedBackID', None)
         collect_status = request_dict.get('collectStatus', None)
         if not all([feedBackID, collect_status]):
             return response.json(444)
         feedBackID = int(feedBackID)
         collect_status = int(collect_status)
-        feed_back_qs = FeedBackModel.objects.filter(id=feedBackID, collect_status=collect_status)  # 判断是否存在
-        if feed_back_qs.exists():
+        feed_back_qs = FeedBackModel.objects.filter(id=feedBackID, collect_status=collect_status)
+        if feed_back_qs.exists():  # 判断是否已收藏
             feed_qs = feed_back_qs.first()
             feed_qs.collect_status = 0
             feed_qs.save()