v4.2 科目管理优化与多项修复清理
1. 科目管理:代码长度放宽至50(含数据库升级v4.2)、编辑可清空代码、重命名查重、新增 ↑↓ 快捷排序(批量重排接口)、空代码不再显示占位 2. 修复单人加减分提交空名单:showSinglePointsModal 三处重复定义收口到 points-mgmt 并共享选中状态 3. SMTP:SMTP_FROM 默认取 SMTP_USER、SMTP_ENABLED 兼容 1/yes/on、启动日志打印邮件状态、新增邮件测试接口与按钮(返回真实 SMTP 错误) 4. 密码:加密改为 bcrypt 库直连(修复 passlib 兼容问题)、重置密码不再依赖影响行数、前端统一展示422校验错误 5. 冗余清理:删除未用导入/Schema/函数、死文件 admin.js 与 sanitize.py、重复 escapeHtml、重复CSS、重复脚本加载 6. 修复11个文件被写入的 UTF-8 BOM 7. 文档与版本同步至4.2
This commit is contained in:
1 parent
990f44bf22
commit
1068bc6def
58 files changed
+366
-533
No files matched your search
@@ -9,7 +9,7 @@
|
||||
# 版权所有 © Sea Network Technology Studio
|
||||
# ===========================================
|
||||
|
||||
from typing import Dict, Any, List, Optional
|
||||
from typing import Dict, Any, Optional, List
|
||||
|
||||
from models.subject import SubjectModel
|
||||
from utils.logger import get_logger
|
||||
@@ -36,27 +36,47 @@ class SubjectService:
|
||||
subject_code: Optional[str],
|
||||
sort_order: int = 0
|
||||
) -> Dict[str, Any]:
|
||||
"""创建科目"""
|
||||
"""创建科目(科目代码留空存 NULL)"""
|
||||
name = (subject_name or "").strip()
|
||||
if not name:
|
||||
return {"success": False, "message": "科目名称不能为空"}
|
||||
code = (subject_code or "").strip() or None
|
||||
|
||||
# 检查是否已存在
|
||||
existing = await SubjectModel.get_by_name(subject_name)
|
||||
existing = await SubjectModel.get_by_name(name)
|
||||
if existing:
|
||||
return {"success": False, "message": "科目名称已存在"}
|
||||
|
||||
subject_id = await SubjectModel.create(
|
||||
subject_name=subject_name,
|
||||
subject_code=subject_code,
|
||||
subject_name=name,
|
||||
subject_code=code,
|
||||
sort_order=sort_order
|
||||
)
|
||||
|
||||
if subject_id:
|
||||
logger.info(f"创建科目: {subject_name}")
|
||||
logger.info(f"创建科目: {name}")
|
||||
return {"success": True, "subject_id": subject_id}
|
||||
else:
|
||||
return {"success": False, "message": "创建科目失败"}
|
||||
|
||||
@staticmethod
|
||||
async def update_subject(subject_id: int, **kwargs) -> Dict[str, Any]:
|
||||
"""更新科目"""
|
||||
"""更新科目(科目代码传空字符串表示清空)"""
|
||||
subject = await SubjectModel.get_by_id(subject_id)
|
||||
if not subject:
|
||||
return {"success": False, "message": "科目不存在"}
|
||||
|
||||
if "subject_name" in kwargs:
|
||||
name = (kwargs.get("subject_name") or "").strip()
|
||||
if not name:
|
||||
return {"success": False, "message": "科目名称不能为空"}
|
||||
existing = await SubjectModel.get_by_name(name)
|
||||
if existing and existing["subject_id"] != subject_id:
|
||||
return {"success": False, "message": "科目名称已存在"}
|
||||
kwargs["subject_name"] = name
|
||||
if "subject_code" in kwargs:
|
||||
kwargs["subject_code"] = (kwargs.get("subject_code") or "").strip() or None
|
||||
|
||||
result = await SubjectModel.update(subject_id, **kwargs)
|
||||
|
||||
if result:
|
||||
@@ -65,6 +85,15 @@ class SubjectService:
|
||||
else:
|
||||
return {"success": False, "message": "更新科目失败"}
|
||||
|
||||
@staticmethod
|
||||
async def reorder_subjects(subject_ids: List[int]) -> Dict[str, Any]:
|
||||
"""按新顺序批量更新科目排序"""
|
||||
if not subject_ids:
|
||||
return {"success": False, "message": "排序列表不能为空"}
|
||||
await SubjectModel.reorder(subject_ids)
|
||||
logger.info(f"科目排序已更新: {subject_ids}")
|
||||
return {"success": True}
|
||||
|
||||
@staticmethod
|
||||
async def delete_subject(subject_id: int) -> Dict[str, Any]:
|
||||
"""删除科目(真正删除记录)"""
|
||||
|
||||
Reference in new issue
Block a user