-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from 2024-SummerBootcamp-Team/develop
[main] main Merge
- Loading branch information
Showing
17 changed files
with
108 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from fastapi import APIRouter, Depends | ||
from sqlalchemy.orm import Session | ||
|
||
from app.database.session import get_db | ||
from app.schemas.character import CharacterList | ||
from app.schemas.response import ResultResponseModel | ||
from app.services import character_service | ||
|
||
router = APIRouter( | ||
prefix="/characters", | ||
tags=["Characters"] | ||
) | ||
|
||
|
||
# 캐릭터 목록 조회 | ||
@router.get("", response_model=ResultResponseModel, summary="캐릭터 목록 조회", description="캐릭터 목록 및 정보를 조회합니다.") | ||
def read_characters(db: Session = Depends(get_db), skip: int = 0, limit: int = 100): | ||
characters = character_service.get_characters(db, skip=skip, limit=limit) | ||
return ResultResponseModel(code=200, message="캐릭터 목록을 조회했습니다.", data=CharacterList(characters=characters)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from pydantic import BaseModel | ||
from datetime import datetime | ||
from typing import List | ||
|
||
class CharacterDetail(BaseModel): | ||
id: int | ||
name: str | ||
image_url: str | ||
|
||
class Config: | ||
from_attributes = True | ||
|
||
class CharacterList(BaseModel): | ||
characters: List[CharacterDetail] | ||
|
||
class Config: | ||
from_attributes = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
from sqlalchemy.orm import Session | ||
from ..models.character import Character as CharacterModel | ||
from ..models.character import Character | ||
from ..schemas.character import CharacterDetail, CharacterList | ||
|
||
|
||
def get_character(db: Session, character_id: int): | ||
return db.query(CharacterModel).filter(CharacterModel.id == character_id).first() | ||
return db.query(Character).filter(Character.id == character_id).first() | ||
|
||
|
||
def get_character_by_name(db: Session, character_name: str): | ||
return db.query(CharacterModel).filter(CharacterModel.name == character_name).first() | ||
return db.query(Character).filter(Character.name == character_name).first() | ||
|
||
|
||
def get_characters(db: Session, skip: int = 0, limit: int = 100): | ||
characters = db.query(Character).filter(Character.is_deleted == False).offset(skip).limit(limit).all() | ||
character_list = [CharacterDetail(id=character.id, name=character.name, image_url=character.image_url) for character in characters] | ||
return character_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.