|
@@ -0,0 +1,37 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+"""
|
|
|
+@Time : 2022/5/9 10:51
|
|
|
+@Auth : Locky
|
|
|
+@File :gatewayController.py
|
|
|
+@IDE :PyCharm
|
|
|
+"""
|
|
|
+from django.views.generic.base import View
|
|
|
+
|
|
|
+from Object.ResponseObject import ResponseObject
|
|
|
+
|
|
|
+
|
|
|
+class GatewayView(View):
|
|
|
+ def get(self, request, *args, **kwargs):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
+ operation = kwargs.get('operation')
|
|
|
+ return self.validation(request.GET, request, operation)
|
|
|
+
|
|
|
+ def post(self, request, *args, **kwargs):
|
|
|
+ request.encoding = 'utf-8'
|
|
|
+ operation = kwargs.get('operation')
|
|
|
+ return self.validation(request.POST, request, operation)
|
|
|
+
|
|
|
+ def validation(self, request_dict, request, operation):
|
|
|
+ response = ResponseObject()
|
|
|
+ if operation == 'gatewayPush': # 网关推送
|
|
|
+ return self.gatewayPush(request_dict, response)
|
|
|
+ else:
|
|
|
+ return response.json(414)
|
|
|
+
|
|
|
+ def gatewayPush(self, request_dict, response):
|
|
|
+ serial_number = request_dict.get('serial_number', None)
|
|
|
+
|
|
|
+ try:
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ return response.json(500, repr(e))
|