Skip to content

Commit

Permalink
Merge pull request #96 from 2024-SummerBootcamp-Team/feat/#42
Browse files Browse the repository at this point in the history
[feat/#42] 목소리 상세 정보 조회 character_image 추가
  • Loading branch information
dlwhsk0 authored Jul 21, 2024
2 parents 6e4b3a8 + f3ced47 commit 0439a72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
6 changes: 2 additions & 4 deletions app/routers/voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ..schemas.response import ResultResponseModel
from app.config.aws.s3Client import upload_voice

from app.schemas.voice import VoiceBase, VoiceBaseList, VoiceDetailList
from app.schemas.voice import VoiceDetail, VoiceDetailList


router = APIRouter(
Expand Down Expand Up @@ -55,9 +55,7 @@ def read_voices_in_chat_room(chat_id: int, db: Session = Depends(get_db)):
@router.get("/{voice_id}", response_model=ResultResponseModel, summary="저장한 목소리 상세 조회", description="특정 목소리의 상세 정보를 조회합니다.")
def read_voice(voice_id: int, db: Session = Depends(get_db)):
voice = voice_service.get_voice(db, voice_id=voice_id)
if not voice:
raise HTTPException(status_code=404, detail="목소리 정보를 불러오는데 실패했습니다.")
return ResultResponseModel(code=200, message="목소리 상세 정보를 조회했습니다.", data=VoiceBase.from_orm(voice))
return ResultResponseModel(code=200, message="목소리 상세 정보를 조회했습니다.", data=voice)


# 저장한 목소리 소프트 삭제
Expand Down
18 changes: 0 additions & 18 deletions app/schemas/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@
from datetime import datetime


class VoiceBase(BaseModel):
id: int
bubble_id: int
audio_url: str
content: str
created_at: datetime

class Config:
from_attributes = True


class VoiceBaseList(BaseModel):
voices: List[VoiceBase]

class Config:
from_attributes = True


class VoiceDetail(BaseModel):
id: int
chat_id: int
Expand Down
14 changes: 13 additions & 1 deletion app/services/voice_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ def get_voices_by_chat_id(db: Session, chat_id: int):

# 단일 목소리 상세 조회
def get_voice(db: Session, voice_id: int):
return db.query(Voice).filter(Voice.id == voice_id, Voice.is_deleted == False).first()
voice = db.query(Voice).filter(Voice.id == voice_id, Voice.is_deleted == False).first()
if not voice:
raise HTTPException(status_code=404, detail="목소리 정보를 불러오는데 실패했습니다.")
return VoiceDetail(
id=voice.id,
chat_id=voice.bubble.chat_id,
character=voice.bubble.chat.character.name,
character_image=voice.bubble.chat.character.image_url,
bubble_id=voice.bubble_id,
audio_url=voice.audio_url,
content=voice.content,
created_at=voice.created_at
)


# 저장한 목소리 하드 삭제
Expand Down

0 comments on commit 0439a72

Please sign in to comment.