|
|
|
@ -8,7 +8,7 @@ from website import consts
|
|
|
|
|
from website import db_mysql
|
|
|
|
|
from website import errors
|
|
|
|
|
from website import settings
|
|
|
|
|
from website.handler import APIHandler, authenticated
|
|
|
|
|
from website.handler import APIHandler, authenticated, operation_log
|
|
|
|
|
from website.util import md5, shortuuid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -19,6 +19,7 @@ class ClassificationAddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_add_str, "添加模型分类", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
|
if not name:
|
|
|
|
@ -53,6 +54,7 @@ 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", "")
|
|
|
|
@ -75,6 +77,7 @@ class ClassificationListHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_list_str, "查询模型分类", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
cur = conn.execute(text("""select id, name from model_classification"""))
|
|
|
|
@ -89,6 +92,7 @@ class ClassificationDeleteHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_delete_str, "删除模型分类", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
classification_id = self.get_int_argument("id")
|
|
|
|
|
if not classification_id:
|
|
|
|
@ -104,12 +108,35 @@ 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):
|
|
|
|
|
"""
|
|
|
|
|
模型列表
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_list_str, "查询模型列表", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
|
pageSize = self.get_int_argument("pageSize", consts.PAGE_SIZE)
|
|
|
|
@ -124,7 +151,7 @@ class ListHandler(APIHandler):
|
|
|
|
|
|
|
|
|
|
param = {}
|
|
|
|
|
|
|
|
|
|
sql_count = "select count(id) from model where del=0 "
|
|
|
|
|
sql_count = "select count(id) from model m where m.del=0 "
|
|
|
|
|
param_count = {}
|
|
|
|
|
|
|
|
|
|
if name:
|
|
|
|
@ -161,6 +188,7 @@ class ListHandler(APIHandler):
|
|
|
|
|
|
|
|
|
|
class ListSimpleHandler(APIHandler):
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_list_str, "查询模型列表", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
|
sql = "select id, name from model where del=0"
|
|
|
|
@ -176,6 +204,7 @@ class AddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "添加模型", consts.op_type_add_str, "添加模型", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
|
model_type = self.get_int_argument(
|
|
|
|
@ -218,6 +247,7 @@ class EditHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "编辑模型", consts.op_type_edit_str, "编辑模型", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
mid = self.get_int_argument("id")
|
|
|
|
|
name = self.get_escaped_argument("name", "")
|
|
|
|
@ -258,6 +288,7 @@ class InfoHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型信息", consts.op_type_list_str, "查询模型信息", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
mid = self.get_int_argument("id")
|
|
|
|
|
if not mid:
|
|
|
|
@ -270,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},
|
|
|
|
@ -300,6 +333,7 @@ class DeleteHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型列表", consts.op_type_delete_str, "删除模型", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
mid = self.get_int_argument("id")
|
|
|
|
|
if not mid:
|
|
|
|
@ -329,6 +363,7 @@ class VersionAddHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_add_str, "添加模型版本", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
mid = self.get_int_argument("model_id")
|
|
|
|
|
version = self.get_escaped_argument("version", "")
|
|
|
|
@ -382,6 +417,7 @@ class VersionEditHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_edit_str, "编辑模型版本", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
version_id = self.get_int_argument("version_id")
|
|
|
|
|
version = self.get_escaped_argument("version", "")
|
|
|
|
@ -445,6 +481,7 @@ class VersionListHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_list_str, "模型版本列表", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
model_id = self.get_int_argument("model_id")
|
|
|
|
|
pageNo = self.get_int_argument("pageNo", 1)
|
|
|
|
@ -524,6 +561,7 @@ class VersionInfoHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_list_str, "查询模型版本详情", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
version_id = self.get_int_argument("version_id")
|
|
|
|
|
response = {
|
|
|
|
@ -606,6 +644,7 @@ class VersionSetDefaultHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_edit_str, "设置模型版本为默认版本", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
version_id = self.get_int_argument("version_id")
|
|
|
|
|
model_id = self.get_int_argument("model_id")
|
|
|
|
@ -644,6 +683,7 @@ class VersionDeleteHandler(APIHandler):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@authenticated
|
|
|
|
|
@operation_log("模型管理", "模型版本", consts.op_type_delete_str, "删除模型版本", "")
|
|
|
|
|
def post(self):
|
|
|
|
|
version_id = self.get_int_argument("version_id")
|
|
|
|
|
if not version_id:
|
|
|
|
|