From 1ea04cbf6ad9ce28803d93e467b849d67e64b111 Mon Sep 17 00:00:00 2001
From: zhouping <zhouping@supervision.ltd>
Date: Wed, 31 Jul 2024 08:34:02 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80pagesize=E7=9A=84=E5=80=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 website/consts.py                                 |  1 +
 website/handlers/alg_model/handler.py             |  3 ++-
 website/handlers/enterprise_busi_model/handler.py |  2 +-
 website/handlers/enterprise_device/handler.py     | 14 +++++++-------
 website/handlers/enterprise_entity/handler.py     |  2 +-
 website/handlers/enterprise_node/handler.py       |  2 +-
 website/handlers/enterprise_server/handler.py     |  5 +++--
 website/handlers/system/handler.py                |  2 +-
 8 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/website/consts.py b/website/consts.py
index b623f1e..d80ea2d 100644
--- a/website/consts.py
+++ b/website/consts.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 """静态配置"""
 
+PAGE_NO = 1
 PAGE_SIZE = 10
 
 # 行业分类
diff --git a/website/handlers/alg_model/handler.py b/website/handlers/alg_model/handler.py
index 49b0e6a..3175b19 100644
--- a/website/handlers/alg_model/handler.py
+++ b/website/handlers/alg_model/handler.py
@@ -130,6 +130,7 @@ class ClassificationEditHandler(APIHandler):
 
         self.finish()
 
+
 class ListHandler(APIHandler):
     """
     模型列表
@@ -485,7 +486,7 @@ class VersionListHandler(APIHandler):
     def post(self):
         model_id = self.get_int_argument("model_id")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 20)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         if not model_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "参数缺失")
 
diff --git a/website/handlers/enterprise_busi_model/handler.py b/website/handlers/enterprise_busi_model/handler.py
index 1d91f19..14d8f06 100644
--- a/website/handlers/enterprise_busi_model/handler.py
+++ b/website/handlers/enterprise_busi_model/handler.py
@@ -38,7 +38,7 @@ class ListHandler(APIHandler):
     @operation_log("企业管理", "业务模型", consts.op_type_list_str, "查询企业部署的业务模型列表", "")
     def post(self):
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 10)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         entity_id = self.get_int_argument("entity_id")
         if not entity_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "参数错误")
diff --git a/website/handlers/enterprise_device/handler.py b/website/handlers/enterprise_device/handler.py
index 7ff1f78..df313cf 100644
--- a/website/handlers/enterprise_device/handler.py
+++ b/website/handlers/enterprise_device/handler.py
@@ -126,9 +126,9 @@ class DeviceClassificationDeleteHandler(APIHandler):
             cur = conn.execute(
                 text(
                     """
-                select d.id from enterprise_device d, device_classification c 
-                where d.classification=c.suid and c.id=:id and c.del=0
-                """
+                    select d.id from enterprise_device d, device_classification c 
+                    where d.classification=c.suid and c.id=:id and c.del=0
+                    """
                 ),
                 {"id": did},
             )
@@ -326,7 +326,7 @@ class DeviceListHandler(APIHandler):
     def post(self):
         node_id = self.get_int_argument("node_id")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 20)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         if not node_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "企业节点不能为空")
         db_device = DB_Device.EnterpriseDeviceRepository()
@@ -425,7 +425,7 @@ class DeviceBasemodelListHandler(APIHandler):
                 errors.ERROR_BAD_REQUEST, "企业节点或设备不能为空"
             )
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 10)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         db_busi_model = DB_BusiModelNodeDevice.EnterpriseBusiModelNodeDeviceRepository()
         busi_models, count = db_busi_model.get_busi_model_by_device(device_id=device_id, pagination=True,
                                                                     page_no=pageNo,
@@ -583,7 +583,7 @@ class StatusListHandler(APIHandler):
         classification = self.get_escaped_argument("classification", "")
         status = self.get_int_argument("status", 1000)
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 20)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
 
         if not entity_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "企业节点不能为空")
@@ -743,7 +743,7 @@ class StatusLogHandler(APIHandler):
     def post(self):
         entity_id = self.get_int_argument("entity_id")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 10)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
 
         db_device = DB_Device.EnterpriseDeviceRepository()
         res = db_device.list_entity_devices(entity_id=entity_id, pageno=pageNo, pagesize=pageSize)
diff --git a/website/handlers/enterprise_entity/handler.py b/website/handlers/enterprise_entity/handler.py
index 47d87b7..a02fdc3 100644
--- a/website/handlers/enterprise_entity/handler.py
+++ b/website/handlers/enterprise_entity/handler.py
@@ -27,7 +27,7 @@ class EntityIndexHandler(APIHandler):
     @operation_log("首页", "企业列表", consts.op_type_list_str, "企业列表")
     async def post(self):
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 10)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         name = self.tostr(self.get_escaped_argument("name", ""))
 
         with self.app_mysql.connect() as conn:
diff --git a/website/handlers/enterprise_node/handler.py b/website/handlers/enterprise_node/handler.py
index cdea5a7..1381446 100644
--- a/website/handlers/enterprise_node/handler.py
+++ b/website/handlers/enterprise_node/handler.py
@@ -244,7 +244,7 @@ class BusimodelHandler(APIHandler):
     def post(self):
         node_id = self.get_int_argument("node_id")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 20)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         if not node_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "企业节点不能为空")
 
diff --git a/website/handlers/enterprise_server/handler.py b/website/handlers/enterprise_server/handler.py
index 2067bce..eead858 100644
--- a/website/handlers/enterprise_server/handler.py
+++ b/website/handlers/enterprise_server/handler.py
@@ -6,6 +6,7 @@ from sqlalchemy import text
 
 from website import errors
 from website import settings
+from website import consts
 from website.db.enterprise_device.enterprise_device import EnterpriseEntityRepository as EntRepo
 from website.db_mysql import to_json_list, to_json
 from website.handler import APIHandler, authenticated, operation_log
@@ -131,7 +132,7 @@ class ListHandler(APIHandler):
         entity_id = self.get_int_argument('entity_id')
         status = self.get_int_argument("status")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 10)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
         if not entity_id:
             raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "entity_id is required")
         if status and status not in (1001, 1002):
@@ -241,7 +242,7 @@ class LogHandler(APIHandler):
     def post(self):
         entity_id = self.get_int_argument('entity_id')
         pageNo = self.get_int_argument('pageNo', 1)
-        pageSize = self.get_int_argument('pageSize', 10)
+        pageSize = self.get_int_argument('pageSize', consts.PAGE_SIZE)
 
         with self.app_mysql.connect() as conn:
             p = {}
diff --git a/website/handlers/system/handler.py b/website/handlers/system/handler.py
index bdb527c..6e43c9c 100644
--- a/website/handlers/system/handler.py
+++ b/website/handlers/system/handler.py
@@ -140,7 +140,7 @@ class LogHandler(APIHandler):
         start = self.get_escaped_argument("startDate", "")
         end = self.get_escaped_argument("endDate", "")
         pageNo = self.get_int_argument("pageNo", 1)
-        pageSize = self.get_int_argument("pageSize", 20)
+        pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
 
         user_list = user.split(",") if user else []
         with self.app_mysql.connect() as conn: