Skip to content

Commit 0ee534f

Browse files
committed
Merge branch 'dev' of https://github.com/SKT-FlyAI-BoraMettugi/BE into dev
2 parents 4db24df + 6f8b9de commit 0ee534f

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

crud/theme.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from sqlalchemy.orm import Session
2+
from fastapi import HTTPException
23
from typing import List
34
from models.theme import Theme
45
from schemas.theme import Theme_list, Theme_per
@@ -12,15 +13,17 @@ def get_themes(db: Session) -> List[Theme_list]:
1213
Theme.theme_id,
1314
Theme.theme_name,
1415
Theme.theme_ex, # None 허용
15-
Theme.profile_img
16+
Theme.profile_img,
17+
Theme.background_img
1618
).all()
1719

1820
return [ # 튜플을 ThemeList로 변환
1921
Theme_list(
2022
theme_id=row[0],
2123
theme_name=row[1],
2224
theme_ex=row[2],
23-
profile_img=row[3]
25+
profile_img=row[3],
26+
background_img=row[4]
2427
)
2528
for row in themes
2629
]
@@ -46,7 +49,7 @@ def get_per_theme(theme_id: int, user_id: int, db: Session) -> List[Theme_per]:
4649
# 1) Theme 정보 가져오기
4750
theme = db.query(Theme).filter(Theme.theme_id == theme_id).one_or_none()
4851
if not theme:
49-
return []
52+
raise HTTPException(status_code=404, detail="Theme not found")
5053

5154
# 2) 문제 리스트(stage ASC)
5255
questions = (
@@ -122,10 +125,8 @@ def get_per_theme(theme_id: int, user_id: int, db: Session) -> List[Theme_per]:
122125
theme_id=q.theme_id,
123126
user_id=user_id,
124127
stage=stage_val,
125-
126128
theme_name=theme.theme_name,
127-
background_img=theme.background_img,
128-
129+
question_id=q.question_id,
129130
high_succ_color=high_succ_color,
130131
high_fail_color=high_fail_color,
131132
mid_succ_color=mid_succ_color,

models/badges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class Badges(Base):
99
user_id = Column(BigInteger, ForeignKey("users.user_id"), autoincrement=True, nullable=False) # 사용자 번호
1010
theme_id = Column(BigInteger, ForeignKey("theme.theme_id"), autoincrement=True, nullable=False) # 테마 번호
1111

12-
grade = Column(Enum("","","", name="badge_grade"), nullable=True) # 배지 등급
12+
grade = Column(Enum("gold","silver","copper", name="badge_grade"), nullable=True) # 배지 등급
1313
created_date = Column(DateTime, server_default=func.now()) # 배지 생성 시간
1414
updated_date = Column(DateTime, onupdate=func.now()) # 배지 수정 시간

schemas/theme.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ class Theme_list(BaseModel):
66
theme_name: str
77
theme_ex: Optional[str]
88
profile_img: str
9+
background_img: str
910

1011
class Theme_per(BaseModel):
1112
theme_id: int
1213
user_id: int
1314
stage: int
14-
15-
theme_id: int
15+
question_id: int
1616
theme_name: str
1717

18-
background_img: str
19-
2018
# 1~4
2119
high_succ_color: Optional[str] = None
2220
high_fail_color: Optional[str] = None

0 commit comments

Comments
 (0)