添加系统日志

release
周平 10 months ago
parent adff8d5993
commit 5b962e02ef

@ -305,7 +305,9 @@ command 可以使用动态参数,例如:--port=88%(process_num)02d默认
Dockerfile中首行配置 FROM 192.168.10.94:5000/generalai:v1使用的是开发环境的docker registry镜像
这个image中包含工程运行需要的基础环境包括各种包supervisor
镜像制作docker build -t lemon .
镜像制作:
docker build -t lemon .
镜像导出:
export:
docker export lemon_web lemon.tar # lemon_web是docker-compose.yml中的container name, 或者使用container id

@ -48,7 +48,7 @@ CREATE TABLE `enterprise` (
`industry` int NOT NULL,
`contact` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`phone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`summary` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`summary` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
`logo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL,
`account` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
`pwd` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,

@ -2,6 +2,7 @@ server {
listen 8989;
server_name 192.168.10.94;
client_max_body_size 300M;
root /app/lemon/dist;
location ^~ /api {

@ -46,3 +46,26 @@ device_status_map = {
system_status_not_active = 9000 # 未激活
system_status_activated = 9001 # 已激活
system_status_expire_atall = 9003 # 完全过期
op_type_add = 1001 # 新增
op_type_add_str = u"新增"
op_type_edit = 1002 # 编辑
op_type_edit_str = u"编辑"
op_type_list = 1003 # 查询
op_type_list_str = u"查询"
op_type_delete = 1004 # 删除
op_type_delete_str = u"删除"
op_type_upload = 1005 # 上传
op_type_upload_str = u"上传"
op_type_map = {
op_type_add: op_type_add_str,
op_type_edit: op_type_edit_str,
op_type_list: op_type_list_str,
op_type_delete: op_type_delete_str,
op_type_upload: op_type_upload_str,
}

@ -97,4 +97,4 @@ class ModelRepositry(object):
def get_model_count(self) -> int:
with get_session() as session:
return session.query(Model).count()
return session.query(Model).filter(Model.delete == 0).count()

@ -19,7 +19,7 @@ def get_enterprise_device_count(id: int) -> int:
# 获取所有企业实体数量
def get_enterprise_entity_count(engine: Any) -> int:
with engine.connect() as conn:
count_sql_text = "select count(*) from enterprise "
count_sql_text = "select count(*) from enterprise where del=0 "
count = conn.execute(text(count_sql_text)).fetchone()
if count:
return count[0]

@ -496,7 +496,7 @@ def authenticated_admin(method):
return wrapper
def operation_log(primary_menu, sub_menu, ope_type, content, comment):
def operation_log(primary_menu, sub_menu, ope_type, content, comment=""):
"""
Add logging to a function. level is the logging
level, name is the logger name, and message is the
@ -507,6 +507,7 @@ def operation_log(primary_menu, sub_menu, ope_type, content, comment):
def decorate(func):
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
try:
with self.app_mysql.connect() as conn:
conn.execute(text(
"insert into sys_log(user, ip, primary_menu, sub_menu, op_type, content, comment) "
@ -523,6 +524,8 @@ def operation_log(primary_menu, sub_menu, ope_type, content, comment):
}
)
conn.commit()
except Exception as e:
logging.info("operation log error: %s" % e)
return func(self, *args, **kwargs)

@ -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:
@ -110,6 +114,7 @@ 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 +129,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 +166,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 +182,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 +225,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 +266,7 @@ class InfoHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型信息", consts.op_type_list_str, "查询模型信息", "")
def post(self):
mid = self.get_int_argument("id")
if not mid:
@ -300,6 +309,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 +339,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 +393,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 +457,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 +537,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 +620,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 +659,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:

@ -9,7 +9,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
class ListHandler(APIHandler):
@ -38,6 +38,7 @@ 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)
@ -104,6 +105,7 @@ class SyncHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型运行库", consts.op_type_list_str, "查询模型运行库镜像", "")
def post(self):
host = self.get_escaped_argument("host", "")
port = self.get_int_argument("port")
@ -142,6 +144,7 @@ class AddHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型运行库", consts.op_type_add_str, "新建模型运行库", "")
def post(self):
name = self.get_escaped_argument("name", "")
host = self.get_escaped_argument("host", "")
@ -188,6 +191,7 @@ class EditHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型运行库", consts.op_type_edit_str, "编辑模型运行库", "")
def post(self):
id = self.get_int_argument("id")
name = self.get_escaped_argument("name", "")
@ -195,7 +199,7 @@ class EditHandler(APIHandler):
port = self.get_int_argument("port")
path = self.get_escaped_argument("path", "")
comment = self.get_escaped_argument("comment", "")
if not id or not name or not host or not port or path:
if not id or not name or not host or not port or not path:
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, "parameter error")
with self.app_mysql.connect() as conn:
conn.execute(
@ -235,6 +239,7 @@ class InfoHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型运行库", consts.op_type_list_str, "查询模型运行库信息", "")
def post(self):
hid = self.get_int_argument("id")
if not id:
@ -266,6 +271,7 @@ class DeleteHandler(APIHandler):
"""
@authenticated
@operation_log("模型管理", "模型运行库", consts.op_type_delete_str, "删除模型运行库", "")
def post(self):
hid = self.get_int_argument("id")
if not id:

@ -3,8 +3,8 @@ import json
import logging
from sqlalchemy import text
from website import db_mysql, errors
from website.handler import APIHandler, authenticated
from website import db_mysql, errors, consts
from website.handler import APIHandler, authenticated, operation_log
from website.util import shortuuid
from website.db.enterprise_busi_model import enterprise_busi_model as DB_BusiModel
from website.db.enterprise_busi_model import enterprise_busi_model_node_device as DB_BusiModelNodeDevice
@ -35,6 +35,7 @@ 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", 10)
@ -63,6 +64,7 @@ class AddHandler(APIHandler):
- 返回值
"""
@authenticated
@operation_log("企业管理", "业务模型", consts.op_type_add_str, "添加企业部署的业务模型", "")
def post(self):
entity_id = self.get_int_argument("entity_id")
name = self.get_escaped_argument("name", "")
@ -131,6 +133,7 @@ class InfoHandler(APIHandler):
```
"""
@authenticated
@operation_log("企业管理", "业务模型", consts.op_type_list_str, "查询企业部署的业务模型详情")
def post(self):
busimodel_id = self.get_int_argument("id")
@ -189,6 +192,7 @@ class EditHandler(APIHandler):
- 返回值
"""
@authenticated
@operation_log("企业管理", "业务模型", consts.op_type_edit_str, "编辑企业部署的业务模型")
def post(self):
busimodel_id = self.get_int_argument("id")
@ -255,6 +259,7 @@ class EditHandler(APIHandler):
class DeleteHandler(APIHandler):
@authenticated
@operation_log("企业管理", "业务模型", consts.op_type_delete_str, "删除企业部署的业务模型")
def post(self):
busimodel_id = self.get_int_argument("id")
if not busimodel_id:

@ -16,7 +16,7 @@ from website.db.enterprise_busi_model import enterprise_busi_model_node_device a
from website.db.enterprise_device import enterprise_device as DB_Device
from website.db.enterprise_node import enterprise_node as DB_Node
from website.db.enterprise_node import enterprise_node_base_model_conf as DB_NodeBaseModelConf
from website.handler import APIHandler, authenticated
from website.handler import APIHandler, authenticated, operation_log
from website.util import date_util
from website.util import shortuuid
@ -37,6 +37,7 @@ class DeviceClassificationAddHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_add_str, "添加设备分类")
def post(self):
name = self.get_escaped_argument("name", "")
with self.app_mysql.connect() as conn:
@ -82,6 +83,7 @@ class DeviceClassificationHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_list_str, "设备分类列表")
def post(self):
with self.app_mysql.connect() as conn:
cur = conn.execute(
@ -105,6 +107,7 @@ class DeviceClassificationDeleteHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_delete_str, "删除设备分类")
def post(self):
did = self.get_int_argument("id")
@ -151,6 +154,7 @@ class DeviceAddHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_add_str, "企业节点,添加设备")
def post(self):
entity_id = self.get_int_argument("entity_id")
node_id = self.get_int_argument("node_id")
@ -204,6 +208,7 @@ class DeviceEditHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_edit_str, "企业节点,编辑设备")
def post(self):
device_id = self.get_int_argument("device_id")
name = self.get_escaped_argument("name", "")
@ -243,6 +248,7 @@ class DeviceDeleteHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_delete_str, "企业节点,删除设备")
def post(self):
# node_id = self.get_int_argument('node_id')
device_id = self.get_int_argument("device_id")
@ -281,6 +287,7 @@ class DeviceListHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_list, "企业节点,设备列表")
def post(self):
node_id = self.get_int_argument("node_id")
pageNo = self.get_int_argument("pageNo", 1)
@ -329,7 +336,8 @@ class DeviceInfoHandler(APIHandler):
}
```
"""
@authenticated
@operation_log("企业管理", "设备管理", consts.op_type_list, "企业节点,设备信息")
def post(self):
device_id = self.get_int_argument("device_id")
if not device_id:
@ -374,6 +382,7 @@ class DeviceBasemodelListHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list, "企业节点,节点信息 -> 设备列表 -> 基础模型配置 -> 模型列表")
def post(self):
device_id = self.get_int_argument("device_id")
if not device_id:
@ -395,9 +404,6 @@ class DeviceBasemodelListHandler(APIHandler):
busi_model_id = item["busi_model_id"]
busi_model_name = item["name"]
base_model_list = json.loads(item["base_models"])
logging.info("##############################################################")
logging.info(base_model_list)
logging.info("##############################################################")
base_models = []
for base_model in base_model_list:
base_model_id = base_model["id"]
@ -448,6 +454,8 @@ class DeviceBaseModelCustomConfigHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_add_str,
"企业节点,节点信息 -> 设备列表 -> 基础模型配置 -> 基础模型参数配置")
def post(self):
device_id = self.get_int_argument("device_id")
node_id = self.get_int_argument("node_id")
@ -533,6 +541,7 @@ class StatusListHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "设备状态", consts.op_type_list_str,"设备状态列表")
def post(self):
entity_id = self.get_int_argument("entity_id")
group = self.get_int_argument("group")
@ -599,6 +608,7 @@ class StatusInfoHandler(APIHandler):
""" """
@authenticated
@operation_log("企业管理", "设备状态", consts.op_type_list_str, "设备信息")
def post(self):
device_id = self.get_int_argument("id")
if not device_id:

@ -12,7 +12,7 @@ from website import settings
from website.db.alg_model.alg_model import ModelRepositry
from website.db.enterprise import enterprise
from website.db.enterprise_device.enterprise_device import EnterpriseDeviceRepository
from website.handler import APIHandler, authenticated
from website.handler import APIHandler, authenticated, operation_log
from website.util import shortuuid, aes
@ -24,6 +24,7 @@ class EntityIndexHandler(APIHandler):
"""首页"""
@authenticated
@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)
@ -119,6 +120,7 @@ class EntityIndexBasecountHandler(APIHandler):
"""首页基础统计书记"""
@authenticated
@operation_log("首页", "企业列表", consts.op_type_list_str, "基础统计数据")
def post(self):
entity_count = enterprise.get_enterprise_entity_count(self.app_mysql)
model_repository = ModelRepositry()
@ -133,6 +135,7 @@ class EntityAddHandler(APIHandler):
"""添加企业"""
@authenticated
@operation_log("首页", "企业列表", consts.op_type_add_str, "添加企业项目")
def post(self):
name = self.tostr(self.get_escaped_argument("name", ""))
province = self.get_escaped_argument("province", "")
@ -203,6 +206,7 @@ class EntityEditHandler(APIHandler):
"""编辑企业"""
@authenticated
@operation_log("首页", "企业列表", consts.op_type_edit_str, "编辑企业项目")
def post(self):
eid = self.get_int_argument("id")
name = self.tostr(self.get_escaped_argument("name", ""))
@ -267,6 +271,7 @@ class EntityInfoHandler(APIHandler):
"""企业信息"""
@authenticated
@operation_log("企业管理", "企业信息", consts.op_type_list_str, "企业信息")
def post(self):
eid = self.get_int_argument("id")
@ -310,6 +315,7 @@ class ModelsHandler(APIHandler):
"""企业模型"""
@authenticated
@operation_log("企业管理", "企业模型", consts.op_type_list_str, "企业模型")
def post(self):
eid = self.get_int_argument("id")
@ -354,6 +360,7 @@ class EntityDeleteHandler(APIHandler):
"""删除企业"""
@authenticated
@operation_log("首页", "企业列表", consts.op_type_delete_str, "删除企业")
def post(self):
eid = self.get_int_argument("id")
@ -369,6 +376,7 @@ class EntityPwdcheckHandler(APIHandler):
"""查看企业密码"""
@authenticated
@operation_log("企业管理", "企业信息", consts.op_type_list_str, "查看企业密码")
def post(self):
eid = self.get_int_argument("id")

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import json
from website import errors
from website import errors, consts
from website.db.enterprise_busi_model import enterprise_busi_model as DB_BusiModel
from website.db.enterprise_busi_model import (
enterprise_busi_model_node_device as DB_BusiModelNodeDevice,
@ -10,7 +10,7 @@ from website.db.enterprise_device import enterprise_device as DB_Device
from website.db.enterprise_entity import enterprise_entity as DB_Entity
from website.db.enterprise_node import enterprise_node as DB_Node
from website.db.enterprise_node import enterprise_node_alert as DB_NodeAlert
from website.handler import APIHandler, authenticated
from website.handler import APIHandler, authenticated, operation_log
from website.util import shortuuid
@ -30,7 +30,8 @@ class AddHandler(APIHandler):
- 返回值
"""
# @authenticated
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_add_str, "添加企业节点")
def post(self):
entity_id = self.get_int_argument("entity_id")
entity_suid = self.get_escaped_argument("entity_suid", "")
@ -83,7 +84,8 @@ class EditHandler(APIHandler):
- 返回值
"""
# @authenticated
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_edit_str, "更新企业节点")
def post(self):
node_id = self.get_int_argument("node_id", 0)
name = self.get_escaped_argument("name", "")
@ -151,6 +153,7 @@ class TreeHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "企业节点树")
def post(self):
entity_id = self.get_escaped_argument("entity_id", "")
name = self.get_escaped_argument("name", "")
@ -183,6 +186,7 @@ class InfoHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "企业节点信息")
def post(self):
node_id = self.get_int_argument("node_id")
@ -198,6 +202,7 @@ class InfoHandler(APIHandler):
class DeleteHandler(APIHandler):
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "删除节点")
def post(self):
node_id = self.get_int_argument("node_id")
if not node_id:
@ -233,6 +238,7 @@ class BusimodelHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "业务模型部署列表")
def post(self):
node_id = self.get_int_argument("node_id")
pageNo = self.get_int_argument("pageNo", 1)
@ -284,6 +290,7 @@ class BusimodelInfoHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "业务模型部署 -> 业务模型信息")
def post(self):
node_id = self.get_int_argument("node_id")
busi_model_id = self.get_int_argument("busi_model_id")
@ -332,6 +339,7 @@ class BusimodelDeployHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_add_str, "业务模型部署 -> 业务模型配置")
def post(self):
node_id = self.get_int_argument("node_id")
busi_model_id = self.get_int_argument("busi_model_id")
@ -403,6 +411,7 @@ class AlertHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_list_str, "节点信息 -> 设备列表 -> 告警设置信息")
def post(self):
node_id = self.get_int_argument("node_id")
if not node_id:
@ -452,6 +461,7 @@ class AlertConfigHandler(APIHandler):
"""
@authenticated
@operation_log("企业管理", "节点设置", consts.op_type_edit_str, "节点信息 -> 设备列表 -> 告警设置,更新配置")
def post(self):
node_id = self.get_int_argument("node_id")
is_sms = self.get_int_argument("is_sms", 0)

@ -30,7 +30,7 @@ class UploadHandler(APIHandler):
logging.info("file_size: %s", file_size)
if file_size > 300 * 1024 * 1024:
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, 'Exceed 300M size limit')
raise errors.HTTPAPIError(errors.ERROR_BAD_REQUEST, '超出300M限定大小')
filetype = filename.split(".") and filename.split(".")[-1] or ""

@ -118,11 +118,11 @@ class ActivateInfoHandler(APIHandler):
date_remain = delta if delta > 0 else 0
data = {
"system": settings.system_info[settings.system_type]["name"],
"license": license_str,
"activate_at": activate_at,
"expire_at": expire_at,
"date_remain": date_remain
# "system": settings.system_info[settings.system_type]["name"],
# "license": license_str,
# "activate_at": activate_at,
# "expire_at": expire_at,
# "date_remain": date_remain
}
self.finish(data)
@ -142,15 +142,15 @@ class LogHandler(APIHandler):
pageNo = self.get_int_argument("pageNo", 1)
pageSize = self.get_int_argument("pageSize", 20)
users = user.split(",")
user_list = user.split(",") if user else []
with self.app_mysql.connect() as conn:
sql = "select user, ip, content, op_type, content from sys_log where 1=1"
sql = "select user, ip, content, op_type, content, create_time from sys_log where 1=1"
sql_count = "select count(*) from sys_log where 1=1"
p = {}
if users:
if user_list:
sql += " and user in :users"
sql_count += " and user in :users"
p["users"] = users
p["users"] = user_list
if start:
sql += " and date_format(create_time, '%Y-%m-%d') >= :start"
sql_count += " and date_format(create_time, '%Y-%m-%d') >= :start"
@ -167,5 +167,7 @@ class LogHandler(APIHandler):
p["pageSize"] = pageSize
res = conn.execute(text(sql), p)
data = to_json_list(res)
for item in data:
item["create_time"] = str(item["create_time"])
self.finish({"count": count, "data": data})

Loading…
Cancel
Save