Voices also has tags now
This commit is contained in:
@@ -7,10 +7,10 @@ from ..db import get_db
|
||||
from ..models import Voice
|
||||
from ..schemas import VoiceCreate, VoiceUpdate, VoiceOut
|
||||
|
||||
router = APIRouter()
|
||||
router = APIRouter(prefix="/voices", tags=["Voices"])
|
||||
|
||||
|
||||
@router.get("/voices")
|
||||
@router.get("")
|
||||
def list_voices(
|
||||
vendor: Optional[str] = None,
|
||||
language: Optional[str] = None,
|
||||
@@ -34,7 +34,7 @@ def list_voices(
|
||||
return {"total": total, "page": page, "limit": limit, "list": voices}
|
||||
|
||||
|
||||
@router.post("/voices", response_model=VoiceOut)
|
||||
@router.post("", response_model=VoiceOut)
|
||||
def create_voice(data: VoiceCreate, db: Session = Depends(get_db)):
|
||||
"""创建声音"""
|
||||
voice = Voice(
|
||||
@@ -58,7 +58,7 @@ def create_voice(data: VoiceCreate, db: Session = Depends(get_db)):
|
||||
return voice
|
||||
|
||||
|
||||
@router.get("/voices/{id}", response_model=VoiceOut)
|
||||
@router.get("/{id}", response_model=VoiceOut)
|
||||
def get_voice(id: str, db: Session = Depends(get_db)):
|
||||
"""获取单个声音详情"""
|
||||
voice = db.query(Voice).filter(Voice.id == id).first()
|
||||
@@ -67,7 +67,7 @@ def get_voice(id: str, db: Session = Depends(get_db)):
|
||||
return voice
|
||||
|
||||
|
||||
@router.put("/voices/{id}", response_model=VoiceOut)
|
||||
@router.put("/{id}", response_model=VoiceOut)
|
||||
def update_voice(id: str, data: VoiceUpdate, db: Session = Depends(get_db)):
|
||||
"""更新声音"""
|
||||
voice = db.query(Voice).filter(Voice.id == id).first()
|
||||
@@ -83,7 +83,7 @@ def update_voice(id: str, data: VoiceUpdate, db: Session = Depends(get_db)):
|
||||
return voice
|
||||
|
||||
|
||||
@router.delete("/voices/{id}")
|
||||
@router.delete("/{id}")
|
||||
def delete_voice(id: str, db: Session = Depends(get_db)):
|
||||
"""删除声音"""
|
||||
voice = db.query(Voice).filter(Voice.id == id).first()
|
||||
|
||||
Reference in New Issue
Block a user