UnicomManageController.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2022 #
  2. # @Time : 2022/7/18 16:16
  3. # @Author : ghl
  4. # @Email : Guanhailogn@asj6.wecom.work
  5. # @File : UnicomManageController.py
  6. # @Software: PyCharm
  7. import datetime
  8. import logging
  9. import time
  10. from django.db import transaction
  11. from django.db.models import Q
  12. from django.views import View
  13. from Model.models import UnicomComboOrderInfo, UnicomCombo, Order_Model, UnicomDeviceInfo
  14. from Object.ResponseObject import ResponseObject
  15. from Object.UnicomObject import UnicomObjeect
  16. class UnicomComboTaskView(View):
  17. def get(self, request, *args, **kwargs):
  18. request.encoding = 'utf-8'
  19. operation = kwargs.get('operation')
  20. return self.validation(request.GET, request, operation)
  21. def post(self, request, *args, **kwargs):
  22. request.encoding = 'utf-8'
  23. operation = kwargs.get('operation')
  24. return self.validation(request.POST, request, operation)
  25. def validation(self, request_dict, request, operation):
  26. response = ResponseObject()
  27. print(request)
  28. if operation == 'get/unicom/info':
  29. return self.get_unicom_info(request_dict, response)
  30. @staticmethod
  31. def get_unicom_info(request_dict, response):
  32. combo_id = request_dict.get('comboID',None)
  33. combo_qs = UnicomCombo.objects.filter(id=combo_id).filter()
  34. if not combo_qs.exists():
  35. return response.json(444)
  36. try:
  37. combo_list = []
  38. for combo_info in combo_qs:
  39. combo_qs.exists()
  40. combo_list.append(combo_info)
  41. res = {'combo_list':combo_list}
  42. return (0,res)
  43. except Exception as e:
  44. return response.json(500,e)