From b2082e0e8bbf2e748d2ad14bc706cbeaa84d5737 Mon Sep 17 00:00:00 2001
From: zhouping <zhouping@supervision.ltd>
Date: Thu, 25 Jul 2024 10:30:11 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 website/handlers/enterprise_device/handler.py | 24 +++++++++++++++++++
 website/handlers/enterprise_device/url.py     |  6 ++---
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/website/handlers/enterprise_device/handler.py b/website/handlers/enterprise_device/handler.py
index 827bc1f..2809d24 100644
--- a/website/handlers/enterprise_device/handler.py
+++ b/website/handlers/enterprise_device/handler.py
@@ -134,6 +134,30 @@ class DeviceClassificationDeleteHandler(APIHandler):
         self.finish()
 
 
+class DeviceClassificationEditHandler(APIHandler):
+    """
+    - 描述:编辑设备分类
+    - 请求方式:post
+    - 请求参数:
+    >- id
+    >- name
+    - 返回值:无
+    """
+
+    @authenticated
+    @operation_log("企业管理", "设备管理", consts.op_type_edit_str, "编辑设备分类")
+    def post(self):
+        did = self.get_int_argument("id")
+        name = self.get_escaped_argument("name", "")
+
+        with self.app_mysql.connect() as conn:
+            conn.execute(
+                text("update device_classification set name=:name WHERE id=:id"),
+                {"id": did, "name": name},
+            )
+            conn.commit()
+        self.finish()
+
 class DeviceAddHandler(APIHandler):
     """
     - 描述:企业节点,添加设备
diff --git a/website/handlers/enterprise_device/url.py b/website/handlers/enterprise_device/url.py
index c012806..6d8aacc 100644
--- a/website/handlers/enterprise_device/url.py
+++ b/website/handlers/enterprise_device/url.py
@@ -5,10 +5,8 @@ from website.handlers.enterprise_device import handler
 handlers = [
     ("/enterprise/device/classification/add", handler.DeviceClassificationAddHandler),
     ("/enterprise/device/classification", handler.DeviceClassificationHandler),
-    (
-        "/enterprise/device/classification/delete",
-        handler.DeviceClassificationDeleteHandler,
-    ),
+    ("/enterprise/device/classification/delete", handler.DeviceClassificationDeleteHandler),
+    ("/enterprise/device/classification/edit", handler.DeviceClassificationEditHandler),
     ("/enterprise/entity/nodes/device/add", handler.DeviceAddHandler),
     ("/enterprise/entity/nodes/device/edit", handler.DeviceEditHandler),
     ("/enterprise/entity/nodes/device/delete", handler.DeviceDeleteHandler),