|
|
@ -36,6 +36,7 @@ class ClassificationAddHandler(APIHandler):
|
|
|
|
conn.execute(
|
|
|
|
conn.execute(
|
|
|
|
text("""insert into model_classification (name, create_time) values (:name, NOW())"""), {"name": name}
|
|
|
|
text("""insert into model_classification (name, create_time) values (:name, NOW())"""), {"name": name}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
conn.commit()
|
|
|
|
|
|
|
|
|
|
|
|
self.finish()
|
|
|
|
self.finish()
|
|
|
|
|
|
|
|
|
|
|
@ -159,15 +160,15 @@ class AddHandler(APIHandler):
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "参数缺失")
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "参数缺失")
|
|
|
|
|
|
|
|
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
sql = text("select id from model_classification where id=:id", {"id": classification})
|
|
|
|
sql = text("select id from model_classification where id=:id")
|
|
|
|
cur = conn.execute(sql)
|
|
|
|
cur = conn.execute(sql, {"id": classification})
|
|
|
|
if not cur.fetchone():
|
|
|
|
if not cur.fetchone():
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "分类不存在")
|
|
|
|
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "分类不存在")
|
|
|
|
|
|
|
|
|
|
|
|
conn.execute(
|
|
|
|
conn.execute(
|
|
|
|
text(
|
|
|
|
text(
|
|
|
|
"""insert into model (name, model_type, classification, comment, create_time)
|
|
|
|
"""insert into model (name, model_type, classification, comment, create_time, update_time)
|
|
|
|
values (:name, :model_type, :classification, :comment, NOW())"""),
|
|
|
|
values (:name, :model_type, :classification, :comment, NOW(), NOW())"""),
|
|
|
|
{"name": name, "model_type": model_type, "classification": classification, "comment": comment}
|
|
|
|
{"name": name, "model_type": model_type, "classification": classification, "comment": comment}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -221,9 +222,13 @@ class InfoHandler(APIHandler):
|
|
|
|
result = {}
|
|
|
|
result = {}
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
with self.app_mysql.connect() as conn:
|
|
|
|
cur = conn.execute(
|
|
|
|
cur = conn.execute(
|
|
|
|
text(
|
|
|
|
text("""
|
|
|
|
"""select m.name, mc.name as classification_name, m.comment, m.update_time
|
|
|
|
select
|
|
|
|
from model m, model_classification mc where m.id=:id and m.classification=c.id"""),
|
|
|
|
m.name, m.model_type, 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
|
|
|
|
|
|
|
|
"""),
|
|
|
|
{"id": mid}
|
|
|
|
{"id": mid}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -233,6 +238,8 @@ class InfoHandler(APIHandler):
|
|
|
|
|
|
|
|
|
|
|
|
data = {
|
|
|
|
data = {
|
|
|
|
"name": result["name"],
|
|
|
|
"name": result["name"],
|
|
|
|
|
|
|
|
"model_type": result["model_type"],
|
|
|
|
|
|
|
|
"classification_id": result["classification_id"],
|
|
|
|
"classification_name": result["classification_name"],
|
|
|
|
"classification_name": result["classification_name"],
|
|
|
|
"comment": result["comment"],
|
|
|
|
"comment": result["comment"],
|
|
|
|
"update_time": str(result["update_time"])
|
|
|
|
"update_time": str(result["update_time"])
|
|
|
@ -395,9 +402,9 @@ class VersionListHandler(APIHandler):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
select mv.id as version_id, mv.version, mv.model_file, mv.update_time, mv.is_default, f.filepath, f.filesize
|
|
|
|
select mv.id as version_id, mv.version, mv.model_file, mv.update_time, mv.is_default, f.filepath, f.filesize
|
|
|
|
from model_version mv
|
|
|
|
from model_version mv
|
|
|
|
left join files f on mv.model_file=f.md5
|
|
|
|
left join files f on mv.model_file=f.md5_str
|
|
|
|
where mv.model_id=:mid and mv.del=0
|
|
|
|
where mv.model_id=:mid and mv.del=0
|
|
|
|
order by mv.version_id desc limit :offset, :limit
|
|
|
|
order by mv.id desc limit :offset, :limit
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
),
|
|
|
|
),
|
|
|
|
{"mid": model_id, "offset": (pageNo - 1) * pageSize, "limit": pageSize}
|
|
|
|
{"mid": model_id, "offset": (pageNo - 1) * pageSize, "limit": pageSize}
|
|
|
|