7b62c2f8b4
## H5 底部导航修复 (Bug #10) - 精简 App.vue,移除重复 tabbar,仅保留全局样式 - uni-page 设置 height: calc(100% - 50px) + overflow-y: auto - 内容区域精确停在底部导航上方,独立滚动不再叠加 - 恢复 custom-tab-bar 组件 ## 项目进度文档 - PROGRESS.md 更新至 10 个 Bug 修复 - 新增 H5 底部导航修复记录 - 新增历史变更条目
90 lines
2.7 KiB
Python
90 lines
2.7 KiB
Python
from fastapi import APIRouter, Depends, HTTPException, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from typing import Annotated, Optional
|
|
from app.database import get_db
|
|
from app.services.followup_engine import FollowupEngine
|
|
from app.api.v1.deps import get_current_user_id
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/strategies")
|
|
async def list_strategies(
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
await engine.ensure_default_strategies()
|
|
return {"strategies": await engine.get_strategies()}
|
|
|
|
|
|
@router.get("/pending")
|
|
async def get_pending_followups(
|
|
page: int = Query(1, ge=1),
|
|
size: int = Query(20, ge=1, le=100),
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
return await engine.get_pending_followups(user_id, page, size)
|
|
|
|
|
|
@router.get("/logs")
|
|
async def get_followup_logs(
|
|
page: int = Query(1, ge=1),
|
|
size: int = Query(20, ge=1, le=100),
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
return await engine.get_followup_logs(user_id, page, size)
|
|
|
|
|
|
@router.post("/{log_id}/send")
|
|
async def mark_followup_sent(
|
|
log_id: str,
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
success = await engine.mark_sent(user_id, log_id)
|
|
if not success:
|
|
raise HTTPException(status_code=404, detail="Followup log not found")
|
|
return {"status": "ok"}
|
|
|
|
|
|
@router.post("/{log_id}/edit")
|
|
async def edit_and_send_followup(
|
|
log_id: str,
|
|
body: dict,
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
edited_text = body.get("edited_text", "")
|
|
if not edited_text:
|
|
raise HTTPException(status_code=400, detail="edited_text is required")
|
|
engine = FollowupEngine(db)
|
|
success = await engine.mark_edited(user_id, log_id, edited_text)
|
|
if not success:
|
|
raise HTTPException(status_code=404, detail="Followup log not found")
|
|
return {"status": "ok"}
|
|
|
|
|
|
@router.get("/stats")
|
|
async def get_followup_stats(
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
return await engine.get_stats(user_id)
|
|
|
|
|
|
@router.post("/scan")
|
|
async def trigger_followup_scan(
|
|
user_id: str = Depends(get_current_user_id),
|
|
db: Annotated[AsyncSession, Depends(get_db)] = None,
|
|
):
|
|
engine = FollowupEngine(db)
|
|
result = await engine.scan_and_followup()
|
|
return result
|