同步更新:重构路由、服务模块,更新前端构建

This commit is contained in:
2025-12-14 21:47:08 +08:00
parent e01a7b5235
commit a346509a5f
87 changed files with 9186 additions and 7826 deletions

52
db/utils.py Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import annotations
import html
from datetime import datetime
from typing import Optional
import pytz
# ==================== 时区处理工具函数 ====================
CST_TZ = pytz.timezone("Asia/Shanghai")
def get_cst_now() -> datetime:
return datetime.now(CST_TZ)
def get_cst_now_str() -> str:
return get_cst_now().strftime("%Y-%m-%d %H:%M:%S")
def parse_cst_datetime(datetime_str: str) -> datetime:
naive = datetime.strptime(datetime_str, "%Y-%m-%d %H:%M:%S")
return CST_TZ.localize(naive)
# ==================== 安全工具(与 app_security 保持兼容) ====================
def escape_html(text: Optional[object]) -> str:
try:
from app_security import escape_html as _escape_html
return _escape_html(text)
except Exception:
if text is None:
return ""
return html.escape(str(text))
def sanitize_sql_like_pattern(pattern: Optional[object]) -> str:
try:
from app_security import sanitize_sql_like_pattern as _sanitize_sql_like_pattern
return _sanitize_sql_like_pattern(pattern)
except Exception:
if pattern is None:
return ""
return str(pattern).replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")