Skip to content

Commit

Permalink
add: ADD 요청시 created 에 URL 을 담고, body를 반환하도록 함
Browse files Browse the repository at this point in the history
body를 반환하도록 함
  • Loading branch information
yunjunghun0116 committed Jul 31, 2024
1 parent 5d0fdf4 commit d7db93a
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions src/main/java/gift/controller/CategoryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public CategoryController(CategoryService categoryService) {
}

@PostMapping
public ResponseEntity<Void> addCategory(@Valid @RequestBody CategoryRequest categoryRequest) {
public ResponseEntity<CategoryResponse> addCategory(@Valid @RequestBody CategoryRequest categoryRequest) {
var category = categoryService.addCategory(categoryRequest);
return ResponseEntity.created(URI.create("/api/categories/" + category.id())).build();
return ResponseEntity.created(URI.create("/api/categories/" + category.id())).body(category);
}

@PutMapping("/{id}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gift/controller/GiftOrderController.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public GiftOrderController(GiftOrderService giftOrderService, OptionService opti
}

@PostMapping
public ResponseEntity<Void> orderOption(@RequestAttribute("memberId") Long memberId, @Valid @RequestBody GiftOrderRequest giftOrderRequest) {
public ResponseEntity<GiftOrderResponse> orderOption(@RequestAttribute("memberId") Long memberId, @Valid @RequestBody GiftOrderRequest giftOrderRequest) {
var order = optionService.orderOption(memberId, giftOrderRequest);
kakaoService.sendOrderResponseWithKakaoMessage(memberId, order);
return ResponseEntity.created(URI.create("/api/orders/" + order.id())).build();
return ResponseEntity.created(URI.create("/api/orders/" + order.id())).body(order);
}

@GetMapping("/{id}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gift/controller/OptionController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public OptionController(OptionService optionService) {
}

@PostMapping
public ResponseEntity<Void> addOption(@PathVariable Long productId, @Valid @RequestBody OptionRequest optionRequest) {
public ResponseEntity<OptionResponse> addOption(@PathVariable Long productId, @Valid @RequestBody OptionRequest optionRequest) {
var option = optionService.addOption(productId, optionRequest);
return ResponseEntity.created(URI.create("/api/products/" + productId + "/options/" + option.id())).build();
return ResponseEntity.created(URI.create("/api/products/" + productId + "/options/" + option.id())).body(option);
}

@PutMapping("/{id}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gift/controller/ProductController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public ProductController(ProductService productService) {
}

@PostMapping
public ResponseEntity<Void> addProduct(@Valid @RequestBody ProductAddRequest productAddRequest) {
public ResponseEntity<ProductResponse> addProduct(@Valid @RequestBody ProductAddRequest productAddRequest) {
var product = productService.addProduct(productAddRequest);
return ResponseEntity.created(URI.create("/api/products/" + product.id())).build();
return ResponseEntity.created(URI.create("/api/products/" + product.id())).body(product);
}

@PutMapping("/{id}")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gift/controller/WishProductController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public WishProductController(WishProductService wishProductService) {
}

@PostMapping
public ResponseEntity<Void> addWishProduct(@Valid @RequestBody WishProductAddRequest wishProductAddRequest, @RequestAttribute("memberId") Long memberId) {
public ResponseEntity<WishProductResponse> addWishProduct(@Valid @RequestBody WishProductAddRequest wishProductAddRequest, @RequestAttribute("memberId") Long memberId) {
var wishProduct = wishProductService.addWishProduct(wishProductAddRequest, memberId);
return ResponseEntity.created(URI.create("/api/wishes/" + wishProduct.id())).build();
return ResponseEntity.created(URI.create("/api/wishes/" + wishProduct.id())).body(wishProduct);
}

@PutMapping("/{id}")
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/gift/controller/api/CategoryApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
public interface CategoryApi {
@Operation(summary = "새 카테고리를 생성한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "카테고리 생성 성공"),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청"),
@ApiResponse(responseCode = "409", description = "카테고리 생성 실패(사유 : 이미 존재하는 이름입니다. )"),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류")
@ApiResponse(responseCode = "201", description = "카테고리 생성 성공", content = @Content(schema = @Schema(implementation = CategoryResponse.class))),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "409", description = "카테고리 생성 실패(사유 : 이미 존재하는 이름입니다. )", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> addCategory(CategoryRequest categoryRequest);
ResponseEntity<CategoryResponse> addCategory(CategoryRequest categoryRequest);

@Operation(summary = "기존 카테고리를 수정한다.")
@ApiResponses(value = {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gift/controller/api/GiftOrderApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public interface GiftOrderApi {

@Operation(summary = "회원의 새 주문을 생성한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "주문 생성 성공"),
@ApiResponse(responseCode = "401", description = "주문 생성 실패(사유 : 카카오 토큰이 만료되었거나, 허용되지 않은 요청입니다.)"),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류")
@ApiResponse(responseCode = "201", description = "주문 생성 성공", content = @Content(schema = @Schema(implementation = GiftOrderResponse.class))),
@ApiResponse(responseCode = "401", description = "주문 생성 실패(사유 : 카카오 토큰이 만료되었거나, 허용되지 않은 요청입니다.)", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> orderOption(Long memberId, GiftOrderRequest giftOrderRequest);
ResponseEntity<GiftOrderResponse> orderOption(Long memberId, GiftOrderRequest giftOrderRequest);

@Operation(summary = "회원의 특정 주문을 조회한다.")
@ApiResponses(value = {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/gift/controller/api/OptionApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public interface OptionApi {

@Operation(summary = "상품에 옵션을 추가한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "옵션 추가 성공"),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청"),
@ApiResponse(responseCode = "409", description = "옵션 추가 실패(사유 : 이미 존재하는 이름입니다. )"),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류")
@ApiResponse(responseCode = "201", description = "옵션 추가 성공", content = @Content(schema = @Schema(implementation = OptionResponse.class))),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "409", description = "옵션 추가 실패(사유 : 이미 존재하는 이름입니다. )", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> addOption(Long productId, OptionRequest optionRequest);
ResponseEntity<OptionResponse> addOption(Long productId, OptionRequest optionRequest);

@Operation(summary = "기존 옵션을 수정한다.")
@ApiResponses(value = {
Expand All @@ -38,7 +38,7 @@ public interface OptionApi {
@Operation(summary = "특정 옵션을 조회한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "특정 옵션 조회 성공", content = @Content(schema = @Schema(implementation = OptionResponse.class))),
@ApiResponse(responseCode = "400", description = "특정 옵션 조회 실패(사유 : 옵션과 연결된 상품 ID 가 아닙니다.)"),
@ApiResponse(responseCode = "400", description = "특정 옵션 조회 실패(사유 : 옵션과 연결된 상품 ID 가 아닙니다.)", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/gift/controller/api/ProductApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public interface ProductApi {

@Operation(summary = "새 상품을 등록한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "상품 등록 성공"),
@ApiResponse(responseCode = "400", description = "상품 등록 실패(사유 : 카카오가 포함된 이름입니다.)"),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청"),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류")
@ApiResponse(responseCode = "201", description = "상품 등록 성공", content = @Content(schema = @Schema(implementation = ProductResponse.class))),
@ApiResponse(responseCode = "400", description = "상품 등록 실패(사유 : 카카오가 포함된 이름입니다.)", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> addProduct(ProductAddRequest productAddRequest);
ResponseEntity<ProductResponse> addProduct(ProductAddRequest productAddRequest);

@Operation(summary = "기존 상품을 수정한다.")
@ApiResponses(value = {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gift/controller/api/WishProductApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public interface WishProductApi {

@Operation(summary = "회원의 위시 리스트에 상품을 추가한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "위시 리스트 추가 성공"),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청"),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류")
@ApiResponse(responseCode = "201", description = "위시 리스트 추가 성공", content = @Content(schema = @Schema(implementation = OptionResponse.class))),
@ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))),
@ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> addWishProduct(WishProductAddRequest wishProductAddRequest, Long memberId);
ResponseEntity<WishProductResponse> addWishProduct(WishProductAddRequest wishProductAddRequest, Long memberId);

@Operation(summary = "회원의 특정 위시 리스트를 수정한다.")
@ApiResponses(value = {
Expand Down

0 comments on commit d7db93a

Please sign in to comment.