tanghongbin 4 年之前
父节点
当前提交
a9cd78baa6
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      Controller/UIDController.py

+ 24 - 0
Controller/UIDController.py

@@ -49,6 +49,8 @@ class UIDView(View):
             return self.do_remove(request_dict, response)
         elif operation == 'download':
             return self.download_txt(token, response)
+        elif operation == 'download_1':
+            return self.download_txt_two(token, response)
         else:
             return response.json(309)
 
@@ -271,3 +273,25 @@ class UIDView(View):
         response['Content-Disposition'] = 'attachment;filename=' + filename
 
         return response
+
+    def download_txt_two(self, token, response):
+
+        uid_qs = UIDModel.objects.filter(status=1)
+
+        if not uid_qs.exists():
+            return response.json(308)
+
+        uid_qs = uid_qs.values()
+        content = ''
+        for item in uid_qs:
+            # print(item)
+            content += item['uid']
+            content += '\r\n'
+
+        content = content[0:len(content) - 1]
+        response = StreamingHttpResponse(content)
+        response['Content-Type'] = 'application/octet-stream'
+        filename = 'uid_need_to_set_up_push.txt'
+        response['Content-Disposition'] = 'attachment;filename=' + filename
+
+        return response