修复bug

release
周平 9 months ago
parent 1421d52f3b
commit 2d2cec8b84

@ -1,13 +1,13 @@
from website.handler import BaseHandler
from sqlalchemy import text
import json
from typing import Any
from sqlalchemy import text
from website.db_mysql import get_session, get_async_session, to_json, to_json_list
import json
# 获取企业模型数量
def get_enterprise_model_count(id: int) -> int:
return 0
@ -68,7 +68,7 @@ def get_enterprise_device_count(entity_id: int = 0, entity_suid: str = "") -> in
async def get_enterprise_model_and_device_count(
entity_id: int = 0, entity_suid: str = ""
entity_id: int = 0, entity_suid: str = ""
) -> (int, int):
model_count = 0
device_count = 0
@ -103,8 +103,6 @@ async def get_enterprise_model_and_device_count(
# if res_device:
# device_count = res_device["device_count"]
sql_device_count = "SELECT COUNT(*) AS device_count FROM enterprise_device WHERE {where_clause} "
sql_base_model = "SELECT base_models FROM enterprise_busi_model WHERE {where_clause} "

@ -108,6 +108,28 @@ class ClassificationDeleteHandler(APIHandler):
self.finish()
class ClassificationEditHandler(APIHandler):
"""
编辑模型分类
"""
@authenticated
@operation_log("模型管理", "模型列表", consts.op_type_edit_str, "编辑模型分类", "")
def post(self):
classification_id = self.get_int_argument("id")
name = self.get_escaped_argument("name", "")
if not classification_id or not name:
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "参数缺失")
with self.app_mysql.connect() as conn:
conn.execute(
text("""update model_classification set name=:name where id=:id"""),
{"name": name, "id": classification_id},
)
conn.commit()
self.finish()
class ListHandler(APIHandler):
"""
模型列表
@ -279,8 +301,10 @@ class InfoHandler(APIHandler):
select
m.name, m.model_type, m.default_version, m.comment, m.update_time,
mc.id as classification_id, mc.name as classification_name
from model m, model_classification mc
where m.id=:id and m.classification=mc.id
from model m
left join model_classification mc
on m.classification=mc.id
where m.id=:id
"""
),
{"id": mid},

@ -5,6 +5,7 @@ handlers = [
("/model/classification/add", handler.ClassificationAddHandler),
("/model/classification/list", handler.ClassificationListHandler),
("/model/classification/delete", handler.ClassificationDeleteHandler),
("/model/classification/edit", handler.ClassificationEditHandler),
("/model/list", handler.ListHandler),
("/model/list/simple", handler.ListSimpleHandler),

Loading…
Cancel
Save