Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ddd61fb
feature: 만약 버전은 어떻게 관리할 수 있을까 ?
YunNote Feb 17, 2024
c2a17d0
feature: 바로 return
YunNote Feb 17, 2024
f1d0672
feature: true만씀
YunNote Feb 17, 2024
07cb76d
feature: 사용하지 않음
YunNote Feb 17, 2024
c4e1569
feature: Objects 클래스 사용
YunNote Feb 17, 2024
19a24d0
feature: Objects 클래스 사용
YunNote Feb 17, 2024
c90f43c
feature: 오탈자
YunNote Feb 17, 2024
82db412
feature: 복수형으로 작성되어야 할듯
YunNote Feb 17, 2024
e0fcb63
feature: Pageable 에 대해서 직접 class 로 구현하여 사용해보시는건 어떨까요
YunNote Feb 17, 2024
1fc0f4e
feature: 미사용 메서드 제거
YunNote Feb 17, 2024
060196a
feature: Response 네이밍
YunNote Feb 17, 2024
5af31d2
feature: API url 복수형. 미사용 서비스 제거, mypage가 필요한지?
YunNote Feb 17, 2024
44918ee
feature: 고정된 response에 대해서 class로 반환하는건 어떨까요?
YunNote Feb 17, 2024
4d7d388
feature: 비밀번호에 대한 Validation 처리
YunNote Feb 17, 2024
789b0cb
feature: Mapper의 활용은 ?
YunNote Feb 17, 2024
927b0e7
feature: config설정은 따로 패키지에 분리
YunNote Feb 17, 2024
3afa661
feature: dto 명칭 대신 request, String 대신 Enum을 받아버림
YunNote Feb 17, 2024
dd9617a
feature: 정적 팩토리 메서드
YunNote Feb 17, 2024
e90ba9f
feature: 정적 팩토리 메서드
YunNote Feb 17, 2024
c4daa01
feature: null에 대한 여러가지 처리
YunNote Feb 17, 2024
d3cd247
feature: 전반적인 Validation 처리 필요
YunNote Feb 17, 2024
a4773a2
feature: 전체리스트 조회와, search를통한 조회 결과같이 항상 같은방향으로 개발이 되는지?
YunNote Feb 17, 2024
71676fa
feature: 컬럼
YunNote Feb 17, 2024
242c2f1
feature: 컬럼
YunNote Feb 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
public class CommonCodeController {

private final CommonCodeService commonCodeService;

//
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

만약 버저닝을 해야한다면 어떻게 관리할 수 있을까요?
URL로도 관리할 수 있지만 header를 통해서도 관리하는 방법에 대해 보시면 좋을것 같습니다!

@GetMapping("/{codeName}")
public ResponseEntity<ApiResponse<List<CommonCodeDto>>> getCommonCode (@PathVariable String codeName){

//
List<CommonCodeDto> codes = commonCodeService.getCodes(codeName);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반환타입을 저장하는 변수를 만드는것도 좋지만 사용처가 없다면 바로 return 문에 넣어주는것은 어떨까요 ?return
ApiResponse.toResponseEntity(GET_COMMON_CODE_SUCCESS, commonCodeService.getCodes(codeName));


return ApiResponse.toResponseEntity(GET_COMMON_CODE_SUCCESS, codes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ public class CommonCodeService {

public List<CommonCodeDto> getCodes(String codeName) {

//
return commonCodeRepository.findAllByUpperNameAndIsUsed(codeName,true)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

항상 true만 반환하는데 spring data jpa 에서 제공하는 true를 그냥 써도 될것같습니다!

참고 사이트 전달드립니다

.stream()
.map(CommonCodeDto::from)
.toList();
}

//
public List<CommonCodeDto> getCodesMapper(String codeName) {

return commonCodeMapper.findAllByUpperNameAndIsUsed(codeName,true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
boolean result = true;
String requestToken = request.getHeader("Authorization");

//
if (requestToken == null || requestToken.isEmpty()) { throw new BusinessException(AcceptInterceptorErrorCode.DOSE_NOT_EXIST_REQUEST_TOKEN); }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Objects.isNull 을 활용하여 null에 대해 명시적으로 관리하면 좋을것 같습니다! 또한 2가지 조건에대해서도 처리 가능합니다!


if (!validRequestToken(requestToken)) { throw new BusinessException(AcceptInterceptorErrorCode.FAILED_VALID_REQUEST_TOKEN); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@
@RestController
@RequestMapping
@RequiredArgsConstructor

//
public class MainContoller {
private final ProductService productService;
private final MainService mainService;

//
@GetMapping("/banner")
ResponseEntity<ApiResponse<BannerDto>> getBanner() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API는 복수형으로 작성하시는걸 추천드립니다


return ApiResponse.toResponseEntity(BannerBusinessCode.GET_BANNER_DATA_SUCCESS, mainService.getBanner());
}


@GetMapping("/recommend-products")
//
ResponseEntity<ApiResponse<Page<RecommendProductsDto>>> getRecommendProducts(Pageable pageable) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pageable를 바로사용해도 좋지만 클래스로 만들어서 Custom하게 사용할 수 있도록 해보시는것도 좋아보입니다!

Page<RecommendProductsDto> recommendProductList = productService.getRecommendProductList(pageable);

Expand All @@ -37,6 +42,8 @@ ResponseEntity<ApiResponse<Page<RecommendProductsDto>>> getRecommendProducts(Pag
}

@GetMapping("/products/rank")

//
ResponseEntity<ApiResponse<Page<ProductDto>>> getProducts(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Controller에서 반환하는 Response타입명을 DTO를 제거하고 Response를 붙여 보시는건 어떠세요?

@RequestParam(name = "sortType", defaultValue = "viewCnt-order") Sort sortType, Pageable pageable) {
Page<ProductDto> productDtos = sortType.sort(productService, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.domain.Pageable;


//
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort가 Enum인데 패키지의 위치가 controller에 있습니다. 패키지의 위치 조절이 필요해 보입니다 .

public enum Sort {

VIEW_COUNT_PRODUCT_ORDER("viewCnt-order") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
public interface ProductRepository extends JpaRepository<Product, Long> {
Page<Product> findByProductNameContaining(String keyword, Pageable pageable);

//
Page<Product> findAllByOrderByViewCountDesc(Pageable pageable);

Page<Product> findTop5ByOrderByProductNameDesc(Pageable pageable);

Page<Product> findAllBySafetyStatusEquals(SafetyStatus safetyStatus, Pageable pageable);

Page<Product> findAllByOrderByCreatedAtDesc(Pageable pageable);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

미사용 메서드들은 제거해보시는거 어떨까요


@Query(value = "SELECT p FROM Product p WHERE p.productName = :productName "
Expand Down