Selaa lähdekoodia

新增负载均衡器健康检测接口

locky 2 vuotta sitten
vanhempi
commit
6a603a8b4e
2 muutettua tiedostoa jossa 31 lisäystä ja 1 poistoa
  1. 2 1
      Ansjer/urls.py
  2. 29 0
      Controller/InitController.py

+ 2 - 1
Ansjer/urls.py

@@ -22,7 +22,7 @@ from Controller import FeedBack, EquipmentOTA, EquipmentInfo, AdminManage, AppIn
     OrderTaskController, HistoryUIDController, UIDManageUserController, SerialNumberController, CompanyController, \
     RegionController, VPGController, LanguageController, TestController, DeviceConfirmRegion, S3GetStsController, \
     DetectControllerV2, PcInfo, PctestController, DeviceDebug, PaymentCycle, \
-    DeviceLogController, CouponController, AiController, ShadowController, AppAccountManagement
+    DeviceLogController, CouponController, AiController, ShadowController, AppAccountManagement, InitController
 from Controller.Cron import CronTaskController
 from Controller.MessagePush import EquipmentMessagePush
 from Controller.Surveys import CloudStorageController
@@ -32,6 +32,7 @@ from django.urls import include
 from Controller.UserDevice import UserDeviceShareController
 
 urlpatterns = [
+    re_path(r'init/(?P<operation>.*)', InitController.InitView.as_view()),
     re_path(r'^testApi/(?P<operation>.*)', TestApi.testView.as_view()),
     re_path(r'^account/authcode', UserController.authCodeView.as_view()),
     re_path(r'^v3/account/generatepictureCodeView/$', UserController.generatePictureCodeView.as_view()),

+ 29 - 0
Controller/InitController.py

@@ -0,0 +1,29 @@
+# @Author    : Rocky
+# @File      : InitController.py
+# @Time      : 2023/4/11 17:26
+from django.http import HttpResponse
+from django.views import View
+
+from Object.ResponseObject import ResponseObject
+
+
+class InitView(View):
+
+    def get(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.GET, operation)
+
+    def post(self, request, *args, **kwargs):
+        request.encoding = 'utf-8'
+        operation = kwargs.get('operation')
+        return self.validation(request.POST, operation)
+
+    def validation(self, request_dict, operation):
+        if operation == 'health-check':  # 负载均衡器健康检测接口
+            return self.health_check(request_dict)
+
+    @staticmethod
+    def health_check(request_dict):
+        response = ResponseObject()
+        return response.json(0)