Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Settings(BaseSettings):

# ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋ฒ„์ „
# deploy๋ธŒ๋žœ์น˜๋กœ ๋ณ‘ํ•ฉํ•  ๋•Œ
app_version: str = "1.3.3"
app_version: str = "1.3.4"

@property
def allowed_origins_list(self) -> list[str]:
Expand Down
8 changes: 7 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from apscheduler.triggers.cron import CronTrigger
from fastapi import HTTPException
from app.config import get_settings
from app.routers import report_router, news_router
from app.routers import report_router, news_router, learning_router
from app.routers.news import init_services as init_news_services
from app.routers.learning import init_repository as init_learning_repository
from app.services.database import DatabaseService
from app.services.analysis import LiquidStocksService, CorrelationService
from app.services.news import NewsColumnService
Expand Down Expand Up @@ -155,6 +156,10 @@ async def lifespan(app: FastAPI):
init_news_services(db_service, liquid_stocks_service, correlation_service, news_column_service, limiter)
logger.info("news_router_initialized")

# Learning ์นด๋“œ Repository ์ดˆ๊ธฐํ™”
init_learning_repository(db_service)
logger.info("learning_repository_initialized")

# ์•ฑ ์ƒํƒœ์— DB ์„œ๋น„์Šค ์ €์žฅ
app.state.db_service = db_service
logger.info("db_service_stored_in_app_state")
Expand Down Expand Up @@ -286,6 +291,7 @@ async def global_exception_handler(request: Request, exc: Exception):
# ๋ผ์šฐํ„ฐ ๋“ฑ๋ก
app.include_router(report_router)
app.include_router(news_router)
app.include_router(learning_router)


@app.get(
Expand Down
62 changes: 62 additions & 0 deletions app/models/learning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from typing import Optional, List, Any, Dict
from pydantic import BaseModel, Field, ConfigDict


class LearningCardBase(BaseModel):
"""ํ•™์Šต ์นด๋“œ ๊ธฐ๋ณธ ๋ชจ๋ธ"""
title: str = Field(..., description="์นด๋“œ ์ œ๋ชฉ")
description: str = Field(..., description="์นด๋“œ ์„ค๋ช…")
contents: Any = Field(..., description="์นด๋“œ ๋‚ด์šฉ (JSON ๋˜๋Š” ๋ฌธ์ž์—ด)")
category: str = Field(..., description="์นดํ…Œ๊ณ ๋ฆฌ")
level: int = Field(..., description="๋ ˆ๋ฒจ (1-5)", ge=1, le=5)
keywords: Optional[List[str]] = Field(None, description="ํ‚ค์›Œ๋“œ ๋ฆฌ์ŠคํŠธ")
image_urls: Optional[List[str]] = Field(None, description="์ด๋ฏธ์ง€ URL ๋ฆฌ์ŠคํŠธ")


class LearningCardCreate(LearningCardBase):
"""ํ•™์Šต ์นด๋“œ ์ƒ์„ฑ ์š”์ฒญ ๋ชจ๋ธ"""
pass


class LearningCardUpdate(BaseModel):
"""ํ•™์Šต ์นด๋“œ ์ˆ˜์ • ์š”์ฒญ ๋ชจ๋ธ"""
title: Optional[str] = Field(None, description="์นด๋“œ ์ œ๋ชฉ")
description: Optional[str] = Field(None, description="์นด๋“œ ์„ค๋ช…")
contents: Optional[Any] = Field(None, description="์นด๋“œ ๋‚ด์šฉ")
category: Optional[str] = Field(None, description="์นดํ…Œ๊ณ ๋ฆฌ")
level: Optional[int] = Field(None, description="๋ ˆ๋ฒจ", ge=1, le=5)
keywords: Optional[List[str]] = Field(None, description="ํ‚ค์›Œ๋“œ ๋ฆฌ์ŠคํŠธ")
image_urls: Optional[List[str]] = Field(None, description="์ด๋ฏธ์ง€ URL ๋ฆฌ์ŠคํŠธ")


class LearningCardResponse(BaseModel):
"""ํ•™์Šต ์นด๋“œ ์‘๋‹ต ๋ชจ๋ธ"""
model_config = ConfigDict(
populate_by_name=True,
from_attributes=True
)

id: int = Field(..., description="์นด๋“œ ID")
title: str = Field(..., description="์นด๋“œ ์ œ๋ชฉ")
description: str = Field(..., description="์นด๋“œ ์„ค๋ช…")
contents: Any = Field(..., description="์นด๋“œ ๋‚ด์šฉ")
category: str = Field(..., description="์นดํ…Œ๊ณ ๋ฆฌ")
level: int = Field(..., description="๋ ˆ๋ฒจ")
keywords: Optional[List[str]] = Field(None, description="ํ‚ค์›Œ๋“œ ๋ฆฌ์ŠคํŠธ")
image_urls: Optional[List[str]] = Field(None, description="์ด๋ฏธ์ง€ URL ๋ฆฌ์ŠคํŠธ")
created_at: str = Field(..., description="์ƒ์„ฑ ์‹œ๊ฐ„")
updated_at: str = Field(..., description="์ˆ˜์ • ์‹œ๊ฐ„")


class LearningCardsListResponse(BaseModel):
"""ํ•™์Šต ์นด๋“œ ๋ชฉ๋ก ์‘๋‹ต ๋ชจ๋ธ"""
success: bool = Field(..., description="์„ฑ๊ณต ์—ฌ๋ถ€")
total_count: int = Field(..., description="์ „์ฒด ๊ฐœ์ˆ˜")
cards: List[LearningCardResponse] = Field(..., description="์นด๋“œ ๋ชฉ๋ก")


class LearningCardDetailResponse(BaseModel):
"""ํ•™์Šต ์นด๋“œ ์ƒ์„ธ ์‘๋‹ต ๋ชจ๋ธ"""
success: bool = Field(..., description="์„ฑ๊ณต ์—ฌ๋ถ€")
card: LearningCardResponse = Field(..., description="์นด๋“œ ์ •๋ณด")

3 changes: 2 additions & 1 deletion app/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .report import router as report_router
from .news import router as news_router
from .learning import router as learning_router

__all__ = ["report_router", "news_router"]
__all__ = ["report_router", "news_router", "learning_router"]

Loading
Loading