refactor: 重构查询参数实现,替换旧的__init__初始化方式为dataclass+post_init

feat: 新增岗位编码字段与校验
fix: 修复批量删除提示、请求缓存、任务状态等逻辑
perf: 优化表格列展示,移除冗余ID列
build: 降级fastapi版本至0.115.2,更新依赖锁文件
docs: 补充部分代码注释与说明
This commit is contained in:
zhangtao
2026-06-22 00:27:23 +08:00
parent 8949f6dc46
commit afdd805e11
44 changed files with 728 additions and 639 deletions
+13 -2
View File
@@ -6,6 +6,7 @@ from functools import wraps
from typing import Any
from redis.asyncio.client import Redis
from starlette.responses import Response
_ENABLE: bool = True
_EXPIRE: int = 300
@@ -35,9 +36,19 @@ def cache(expire: int | None = None, namespace: str = "default"):
key = _build_key(namespace, func, *args, **kwargs)
cached = await _REDIS.get(key)
if cached:
return json.loads(cached)
data = json.loads(cached)
return Response(
content=json.dumps(data, ensure_ascii=False),
media_type="application/json; charset=utf-8",
status_code=200,
)
result = await func(*args, **kwargs)
await _REDIS.set(key, json.dumps(result), ex=expire or _EXPIRE)
# 提取 Response 对象的 body 进行缓存
if isinstance(result, Response):
body = result.body
else:
body = json.dumps(result).encode()
await _REDIS.set(key, body, ex=expire or _EXPIRE)
return result
return wrapper