v4.4 数据报表/操作日志/系统设置与月度分排行

1. 月度分排行:管理端首页支持总分/月度分切换与月份选择,新增排行榜导出CSV
2. 数据报表:新增考勤/作业统计页(日期范围、汇总与每人明细、CSV导出)
3. 操作日志:新增查看页(操作类型/操作人/日期筛选,分页)
4. 系统设置:密码策略可配置(长度/字符种类),全站改密与重置统一校验、前端提示同步;策略通过公开配置下发
5. 学期归档对比:查看归档时展示与上一学期的分数变化与名次升降
6. 历史记录导出支持按学生分表(每人一段,便于发家长)
7. 移动端适配:导航横向滚动、表格触控滚动、字号与弹窗优化
8. 版本升级至4.4(无数据库结构变更)
This commit is contained in:
canglan committed 2026-10-09 15:00:32 +08:00
1 parent 9a19add6c1
commit 768ea281e0
54 files changed
+1782 -90

No files matched your search

+74 -1
View File
@@ -9,7 +9,8 @@
# 版权所有 © Sea Network Technology Studio
# ===========================================
from utils.database import execute_insert
from typing import Dict, Any, List
from utils.database import execute_insert, execute_one, execute_query
from utils.logger import get_logger
logger = get_logger(__name__)
@@ -62,3 +63,75 @@ class OperationLogModel:
"""
return await execute_insert(sql, (operator_id, operator_name, operator_role,
operation_type, target_type, target_id, details, ip_address))
@staticmethod
def _build_filters(
operation_type: str = None,
operator: str = None,
start_date: str = None,
end_date: str = None
):
conditions = ["1=1"]
params = []
if operation_type:
conditions.append("operation_type = %s")
params.append(operation_type)
if operator:
conditions.append("(operator_name LIKE %s OR operator_role LIKE %s)")
params.extend([f"%{operator}%", f"%{operator}%"])
if start_date:
conditions.append("DATE(created_at) >= %s")
params.append(start_date)
if end_date:
conditions.append("DATE(created_at) <= %s")
params.append(end_date)
return " AND ".join(conditions), params
@staticmethod
async def get_logs(
operation_type: str = None,
operator: str = None,
start_date: str = None,
end_date: str = None,
limit: int = 20,
offset: int = 0
) -> List[Dict[str, Any]]:
"""查询操作日志(分页)"""
where, params = OperationLogModel._build_filters(
operation_type, operator, start_date, end_date
)
sql = f"""
SELECT log_id, operator_id, operator_name, operator_role,
operation_type, target_type, target_id, details, ip_address, created_at
FROM operation_logs
WHERE {where}
ORDER BY log_id DESC
LIMIT %s OFFSET %s
"""
params.extend([limit, offset])
return await execute_query(sql, tuple(params))
@staticmethod
async def count_logs(
operation_type: str = None,
operator: str = None,
start_date: str = None,
end_date: str = None
) -> int:
"""统计操作日志数量"""
where, params = OperationLogModel._build_filters(
operation_type, operator, start_date, end_date
)
result = await execute_one(
f"SELECT COUNT(*) AS total FROM operation_logs WHERE {where}",
tuple(params)
)
return result["total"] if result else 0
@staticmethod
async def get_types() -> List[str]:
"""获取所有操作类型(用于筛选项)"""
rows = await execute_query(
"SELECT DISTINCT operation_type FROM operation_logs ORDER BY operation_type"
)
return [row["operation_type"] for row in rows]