|
6 | 6 | from carrot.app.auth.utils import login_with_header |
7 | 7 |
|
8 | 8 | from carrot.app.auction.services import AuctionService |
9 | | -from carrot.app.auction.schemas import AuctionCreate, AuctionResponse, BidCreate, BidResponse # Pydantic 모델 가정 |
| 9 | +from carrot.app.auction.schemas import AuctionListResponse, AuctionResponse, BidCreate, BidResponse # Pydantic 모델 가정 |
10 | 10 |
|
11 | 11 | from carrot.app.user.models import User |
12 | 12 |
|
13 | 13 | from carrot.app.product.schemas import ProductPostRequest |
14 | 14 |
|
15 | 15 | auction_router = APIRouter() |
16 | 16 |
|
17 | | -# 1. 경매 등록 |
18 | | -@auction_router.post("/", response_model=AuctionResponse) |
19 | | -async def create_new_auction( |
20 | | - owner: Annotated[User, Depends(login_with_header)], |
21 | | - product_data: ProductPostRequest, |
22 | | - auction_data: AuctionCreate, |
23 | | - service: Annotated[AuctionService, Depends(AuctionService.create)], |
24 | | -) -> AuctionResponse: |
25 | | - auction = await service.create_auction_with_product( |
26 | | - owner_id=owner.id, |
27 | | - region_id=owner.region_id, |
28 | | - product_data=product_data, |
29 | | - auction_data=auction_data |
30 | | - ) |
31 | | - return AuctionResponse.model_validate(auction) |
| 17 | +# # 1. 경매 등록 |
| 18 | +# @auction_router.post("/", response_model=AuctionResponse) |
| 19 | +# async def create_new_auction( |
| 20 | +# owner: Annotated[User, Depends(login_with_header)], |
| 21 | +# product_data: ProductPostRequest, |
| 22 | +# auction_data: AuctionCreate, |
| 23 | +# service: Annotated[AuctionService, Depends(AuctionService.create)], |
| 24 | +# ) -> AuctionResponse: |
| 25 | +# auction = await service.create_auction_with_product( |
| 26 | +# owner_id=owner.id, |
| 27 | +# region_id=owner.region_id, |
| 28 | +# product_data=product_data, |
| 29 | +# auction_data=auction_data |
| 30 | +# ) |
| 31 | +# return AuctionResponse.model_validate(auction) |
32 | 32 |
|
33 | 33 | # 2. 경매 목록 조회 (카테고리, 지역 필터링) |
34 | | -@auction_router.get("/", response_model=List[AuctionResponse]) |
| 34 | +@auction_router.get("/", response_model=List[AuctionListResponse]) |
35 | 35 | async def get_auctions( |
36 | 36 | service: Annotated[AuctionService, Depends(AuctionService.create)], |
37 | 37 | category_id: Optional[str] = Query(None, description="카테고리 ID로 필터링"), |
38 | 38 | region_id: Optional[str] = Query(None, description="지역 ID로 필터링"), |
39 | | -) -> List[AuctionResponse]: |
40 | | - |
| 39 | +) -> List[AuctionListResponse]: |
41 | 40 | auctions = await service.list_auctions(category_id, region_id) |
42 | | - return auctions |
| 41 | + return [AuctionListResponse.model_validate(a) for a in auctions] |
43 | 42 |
|
44 | | -# 3. 경매 상세 조회 |
45 | | -@auction_router.get("/{auction_id}", response_model=AuctionResponse) |
46 | | -async def get_auction_detail( |
47 | | - auction_id: str, |
48 | | - service: Annotated[AuctionService, Depends(AuctionService.create)], |
49 | | -) -> AuctionResponse: |
50 | | - auction = await service.get_auction_details(auction_id) |
51 | | - return AuctionResponse.model_validate(auction) |
| 43 | +# # 3. 경매 상세 조회 |
| 44 | +# @auction_router.get("/{auction_id}", response_model=AuctionResponse) |
| 45 | +# async def get_auction_detail( |
| 46 | +# auction_id: str, |
| 47 | +# service: Annotated[AuctionService, Depends(AuctionService.create)], |
| 48 | +# ) -> AuctionResponse: |
| 49 | +# auction = await service.get_auction_details(auction_id) |
| 50 | +# return AuctionResponse.model_validate(auction) |
52 | 51 |
|
53 | 52 | # 4. 입찰하기 |
54 | 53 | @auction_router.post("/{auction_id}/bids", response_model=BidResponse) |
|
0 commit comments