feat: 接入mysql数据库

This commit is contained in:
2026-09-04 17:01:12 +08:00
parent 38310f7b1c
commit 86a0d64182
22 changed files with 765 additions and 146 deletions

View File

@@ -1,31 +1,33 @@
from fastapi import APIRouter
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from schema.agent import ReportRequest
from config.database import get_db
from schema.agent import ReportAgentRequest
from service import agent_service
router = APIRouter(prefix="/agent", tags=["Agent"])
@router.post("/tip/generate")
def generate_tip():
return agent_service.query_tip_agent()
@router.post("/article/generate")
def generate_article(db: Session = Depends(get_db)):
return agent_service.query_article_agent(db)
@router.get("/tip/latest")
def latest_tip():
return agent_service.get_latest_tip()
@router.get("/article/latest")
def latest_article(db: Session = Depends(get_db)):
return agent_service.get_latest_article(db)
@router.post("/recipe/generate")
def generate_recipe():
return agent_service.query_recipe_agent()
def generate_recipe(db: Session = Depends(get_db)):
return agent_service.query_recipe_agent(db)
@router.get("/recipe/latest")
def latest_recipe():
return agent_service.get_latest_recipe()
def latest_recipe(db: Session = Depends(get_db)):
return agent_service.get_latest_recipe(db)
@router.post("/report")
def query_report(req: ReportRequest):
def query_report(req: ReportAgentRequest):
return agent_service.query_report_agent(req)