Skip to content

Commit

Permalink
merge [FIX] 장바구니 API 경로 수정 및 결제 페이지 불러오기 매개변수 required 에러 해결
Browse files Browse the repository at this point in the history
[FIX] 장바구니 API 경로 수정 및 결제 페이지 불러오기 매개변수 required 에러 해결
  • Loading branch information
05AM authored Dec 5, 2023
2 parents dcbd7c3 + 7497f42 commit 08b7950
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class CartController {
description = "알 수 없는 서버 에러가 발생했습니다.",
content = @Content(schema = @Schema(implementation = FailResponse.class)))
})
@PostMapping("/items")
@PostMapping
public ResponseEntity<?> saveCartItem(
@Parameter(hidden = true) @UserId Integer userId,
@RequestBody @Valid SaveCartReq saveCartReq
Expand All @@ -85,7 +85,7 @@ public ResponseEntity<?> saveCartItem(
description = "알 수 없는 서버 에러가 발생했습니다.",
content = @Content(schema = @Schema(implementation = FailResponse.class)))
})
@GetMapping("/items")
@GetMapping
public ResponseEntity<?> getUserCartItem(
@Parameter(hidden = true) @UserId Integer userId
) {
Expand All @@ -111,7 +111,7 @@ public ResponseEntity<?> getUserCartItem(
description = "알 수 없는 서버 에러가 발생했습니다.",
content = @Content(schema = @Schema(implementation = FailResponse.class)))
})
@PatchMapping("/items/{cartId}")
@PatchMapping("/{cartId}")
public ResponseEntity<?> addCartCount(
@Parameter(hidden = true) @UserId Integer userId,
@PathVariable Integer cartId) {
Expand All @@ -138,7 +138,7 @@ public ResponseEntity<?> addCartCount(
description = "알 수 없는 서버 에러가 발생했습니다.",
content = @Content(schema = @Schema(implementation = FailResponse.class)))
})
@DeleteMapping("/items/{cartId}")
@DeleteMapping("/{cartId}")
public ResponseEntity<?> deleteCartCount(
@Parameter(hidden = true) @UserId Integer userId,
@PathVariable Integer cartId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
Expand Down Expand Up @@ -68,8 +67,8 @@ public class OrderController {
@GetMapping("/ordersheet")
public ResponseEntity<?> getOrderSheet(
@Parameter(hidden = true) @UserId Integer userId,
@Parameter(description = "타투 스티커 id") @RequestParam @NotNull(message = "stickerId is null") Integer stickerId,
@Parameter(description = "상품 개수", example = "3") @RequestParam @NotNull(message = "count is null") Integer count
@Parameter(description = "타투 스티커 id") @RequestParam(required = false) Integer stickerId,
@Parameter(description = "상품 개수") @RequestParam(required = false) Integer count
) {
return BaseResponse.success(
SuccessType.GET_SUCCESS, orderFacade.readOrderSheet(ReadOrderSheetReq.of(userId, stickerId, count)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public static ReadOrderSheetReq of(Integer userId, Integer stickerId, Integer co
}

public boolean isCartOrder() {
return stickerId == null && count == null;
}

public boolean isNotCartOrder() {
return stickerId != null && count != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ private StickerOrderInfo getStickerOrderInfo(ReadOrderSheetReq req) {
if (req.isCartOrder()) {
List<Cart> carts = cartService.findByUserId(req.getUserId());
return stickerProvider.getStickerOrderInfoFromCart(carts);
} else {
} else if (req.isNotCartOrder()) {
return stickerProvider.getStickerOrderInfoFromOrder(req.getStickerId(), req.getCount());
} else {
throw new BusinessException(ErrorType.INVALID_ARGUMENT_EXCEPTION);
}
}

Expand Down

0 comments on commit 08b7950

Please sign in to comment.