Skip to content

Commit

Permalink
Merge pull request #106 from kakao-tech-campus-2nd-step3/weekly
Browse files Browse the repository at this point in the history
Weekly 정기 병합
  • Loading branch information
yooonwodyd authored Nov 14, 2024
2 parents fe7f36b + 9c3b228 commit 5b76744
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public ResponseEntity<ApiResponse<Void>> handleResourceNotFoundException(Resourc
public ResponseEntity<ApiResponse<Void>> handleDuplicateRequestException(DuplicateResourceException e) {
return ResponseEntity.badRequest().body(ApiResponse.error(HttpStatus.BAD_REQUEST, e.getMessage()));
}

@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<ApiResponse<Void>> handleIllegalArgumentException(IllegalArgumentException e) {
return ResponseEntity.badRequest().body(ApiResponse.error(HttpStatus.BAD_REQUEST, e.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ResponseEntity<Void> deleteProduct(@PathVariable("productId") Long produc
}

@GetMapping
public ResponseEntity<ProductPage.Paging> getProductsByPage(
public ResponseEntity<ApiResponse<ProductPage.Paging>> getProductsByPage(
@RequestParam("query") String query,
@RequestParam(name = "size", required = false, defaultValue = "20") int size,
@RequestParam("page") int page,
Expand All @@ -97,7 +97,7 @@ public ResponseEntity<ProductPage.Paging> getProductsByPage(
var sort = convertProductSort(productSort);
var pageable = PageRequest.of(page, size, sort);

return ResponseEntity.ok(productService.getProductsByPage(query, pageable));
return ResponseEntity.ok(ApiResponse.success(SuccessCode.OK,productService.getProductsByPage(query, pageable)));
}

@GetMapping("/feed")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package com.helpmeCookies.product.controller.docs;

import com.helpmeCookies.global.ApiResponse.ApiResponse;
import com.helpmeCookies.product.dto.ProductPage;
import com.helpmeCookies.product.dto.ProductPage.Paging;
import com.helpmeCookies.product.util.ProductSort;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Tag(name = "상품 관련 기능", description = "상품 관련 API")
public interface ProductApiDocs {

@Operation(summary = "상품 검색")
ResponseEntity<Paging> getProductsByPage(
String query,
@Parameter(description = "default value 20") int size,
int page,
ProductSort productSort
);

@GetMapping
public ResponseEntity<ApiResponse<Paging>> getProductsByPage(
@RequestParam("query") String query,
@RequestParam(name = "size", required = false, defaultValue = "20") int size,
@RequestParam("page") int page,
@RequestParam("sort") ProductSort productSort
)
}

0 comments on commit 5b76744

Please sign in to comment.