feat: 添加任务管理和字典管理功能,优化系统配置和代码结构

本次提交主要包含以下变更:
1. 新增任务管理模块,支持定时任务的创建、更新、删除和状态管理
2. 新增字典管理模块,用于维护系统中常用的固定数据
3. 优化系统配置,移除Celery,改用APScheduler进行任务调度
4. 修复部分前端组件的样式问题,统一输入框宽度
5. 更新文档和相关图片资源,完善系统功能描述

这些变更旨在增强系统的可维护性和功能性,提供更灵活的任务调度机制和更便捷的字典数据管理方式。
This commit is contained in:
zhangtao
2025-04-12 06:43:27 +08:00
parent d0d3b12383
commit 00b7fe54ba
128 changed files with 6217 additions and 1181 deletions
@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*-
import time
from typing import Union, Dict
from fastapi import APIRouter, Depends, Request, Query, BackgroundTasks, WebSocket
from fastapi.responses import JSONResponse
from fastapi import APIRouter, Depends, Request, BackgroundTasks, WebSocket
from fastapi.responses import JSONResponse, StreamingResponse
from sqlalchemy.ext.asyncio import AsyncSession
from app.config.setting import settings
from app.common.response import ErrorResponse, SuccessResponse, StreamResponse
from app.common.response import ErrorResponse, SuccessResponse
from app.api.v1.services.system.auth_service import (
LoginService,
CaptchaService
@@ -76,3 +77,27 @@ async def logout(
logger.info('退出成功')
return SuccessResponse(msg='退出成功')
return ErrorResponse(msg='退出失败')
# 以下接口为预留,后期会用
@router.post("/background_tasks", summary="模拟fastapi自带后台任务-模拟流式响应")
async def stream_response(background_tasks: BackgroundTasks, message:str):
def task(message):
for i in range(5):
yield f"睡眠 {message} {i}\n"
time.sleep(1)
background_tasks.add_task(task, message)
return StreamingResponse(
data=task(*args, **kwargs),
headers={"X-Custom-Header": "Streaming-Response"},
media_type="text/plain",
)
@router.websocket("/ws", name="websocket")
async def websocket_endpoint(websocket: WebSocket):
# ws://127.0.0.1:8000/ws
await websocket.accept()
while True:
data = await websocket.receive_text()
await websocket.send_text(f"Message text was: {data}")