diff --git a/src/main/java/com/fc/shimpyo_be/domain/favorite/controller/FavoriteRestController.java b/src/main/java/com/fc/shimpyo_be/domain/favorite/controller/FavoriteRestController.java index 866fee22..9980ffab 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/favorite/controller/FavoriteRestController.java +++ b/src/main/java/com/fc/shimpyo_be/domain/favorite/controller/FavoriteRestController.java @@ -8,7 +8,6 @@ import com.fc.shimpyo_be.global.common.ResponseDto; import com.fc.shimpyo_be.global.util.SecurityUtil; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; import org.springframework.http.HttpStatus; @@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -@Slf4j @RestController @RequiredArgsConstructor @RequestMapping("/api/favorites") @@ -28,10 +26,11 @@ public class FavoriteRestController { private final FavoriteService favoriteService; private final SecurityUtil securityUtil; + private static final int DEFAULT_SIZE = 10; + private static final int DEFAULT_PAGE = 0; @PostMapping("/{productId}") public ResponseEntity> register(@PathVariable long productId) { - log.debug("memberId: {}, productId: {}", securityUtil.getCurrentMemberId(), productId); return ResponseEntity.status(HttpStatus.CREATED).body(ResponseDto.res(HttpStatus.CREATED, favoriteService.register(securityUtil.getCurrentMemberId(), productId), "성공적으로 즐겨찾기를 등록했습니다.")); @@ -39,8 +38,7 @@ public ResponseEntity> register(@PathVariable l @GetMapping public ResponseEntity> getFavorites( - @PageableConstraint(Favorite.class) @PageableDefault(size = 10, page = 0) Pageable pageable) { - log.debug("memberId: {}", securityUtil.getCurrentMemberId()); + @PageableConstraint(Favorite.class) @PageableDefault(size = DEFAULT_SIZE, page = DEFAULT_PAGE) Pageable pageable) { return ResponseEntity.status(HttpStatus.OK) .body(ResponseDto.res(HttpStatus.OK, favoriteService.getFavorites( securityUtil.getCurrentMemberId(), pageable), "성공적으로 즐겨찾기 목록을 조회했습니다.")); @@ -48,7 +46,6 @@ public ResponseEntity> getFavorites( @DeleteMapping("/{productId}") public ResponseEntity> cancel(@PathVariable long productId) { - log.debug("memberId: {}, productId: {}", securityUtil.getCurrentMemberId(), productId); return ResponseEntity.status(HttpStatus.OK).body(ResponseDto.res(HttpStatus.OK, favoriteService.delete(securityUtil.getCurrentMemberId(), productId), "성공적으로 즐겨찾기를 취소했습니다.")); diff --git a/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoriteResponseDto.java b/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoriteResponseDto.java index 55ca2b2e..6594df31 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoriteResponseDto.java +++ b/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoriteResponseDto.java @@ -1,12 +1,13 @@ package com.fc.shimpyo_be.domain.favorite.dto; import com.fc.shimpyo_be.domain.favorite.entity.Favorite; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class FavoriteResponseDto { private Long favoriteId; @@ -14,7 +15,7 @@ public class FavoriteResponseDto { private Long productId; @Builder - public FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) { + private FavoriteResponseDto(Long favoriteId, Long memberId, Long productId) { this.favoriteId = favoriteId; this.memberId = memberId; this.productId = productId; diff --git a/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoritesResponseDto.java b/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoritesResponseDto.java index 214e574a..9c45db18 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoritesResponseDto.java +++ b/src/main/java/com/fc/shimpyo_be/domain/favorite/dto/FavoritesResponseDto.java @@ -2,19 +2,20 @@ import com.fc.shimpyo_be.domain.product.dto.response.ProductResponse; import java.util.List; +import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class FavoritesResponseDto { private int pageCount; private List products; @Builder - public FavoritesResponseDto(int pageCount, List products) { + private FavoritesResponseDto(int pageCount, List products) { this.pageCount = pageCount; this.products = products; } diff --git a/src/main/java/com/fc/shimpyo_be/domain/favorite/entity/Favorite.java b/src/main/java/com/fc/shimpyo_be/domain/favorite/entity/Favorite.java index d1d493ea..d4c10bf2 100644 --- a/src/main/java/com/fc/shimpyo_be/domain/favorite/entity/Favorite.java +++ b/src/main/java/com/fc/shimpyo_be/domain/favorite/entity/Favorite.java @@ -30,7 +30,7 @@ public class Favorite { private Product product; @Builder - public Favorite(Long id, Member member, Product product) { + private Favorite(Long id, Member member, Product product) { this.id = id; this.member = member; this.product = product; diff --git a/src/test/java/com/fc/shimpyo_be/domain/favorite/docs/FavoriteRestControllerDocsTest.java b/src/test/java/com/fc/shimpyo_be/domain/favorite/docs/FavoriteRestControllerDocsTest.java index f8d8740d..1c99e2f0 100644 --- a/src/test/java/com/fc/shimpyo_be/domain/favorite/docs/FavoriteRestControllerDocsTest.java +++ b/src/test/java/com/fc/shimpyo_be/domain/favorite/docs/FavoriteRestControllerDocsTest.java @@ -46,8 +46,8 @@ void register() throws Exception { .build(); given(securityUtil.getCurrentMemberId()).willReturn(1L); - given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))).willReturn( - favoriteResponseDto); + given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))) + .willReturn(favoriteResponseDto); // when then mockMvc.perform(post("/api/favorites/{productId}", 1L)) @@ -141,8 +141,8 @@ void cancel() throws Exception { .build(); given(securityUtil.getCurrentMemberId()).willReturn(1L); - given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))).willReturn( - favoriteResponseDto); + given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))) + .willReturn(favoriteResponseDto); // when then mockMvc.perform(delete("/api/favorites/{productId}", 1L)) diff --git a/src/test/java/com/fc/shimpyo_be/domain/favorite/unit/controller/FavoriteRestControllerTest.java b/src/test/java/com/fc/shimpyo_be/domain/favorite/unit/controller/FavoriteRestControllerTest.java index 96ddcf62..456fe806 100644 --- a/src/test/java/com/fc/shimpyo_be/domain/favorite/unit/controller/FavoriteRestControllerTest.java +++ b/src/test/java/com/fc/shimpyo_be/domain/favorite/unit/controller/FavoriteRestControllerTest.java @@ -10,7 +10,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fc.shimpyo_be.config.AbstractContainersSupport; import com.fc.shimpyo_be.domain.favorite.dto.FavoriteResponseDto; import com.fc.shimpyo_be.domain.favorite.dto.FavoritesResponseDto; @@ -49,8 +48,6 @@ public class FavoriteRestControllerTest extends AbstractContainersSupport { @MockBean SecurityUtil securityUtil; - ObjectMapper objectMapper = new ObjectMapper(); - @BeforeEach public void setup() { mockMvc = MockMvcBuilders @@ -75,8 +72,8 @@ void _willSuccess() throws Exception { .build(); given(securityUtil.getCurrentMemberId()).willReturn(1L); - given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))).willReturn( - favoriteResponseDto); + given(favoriteService.register(any(Long.TYPE), any(Long.TYPE))) + .willReturn(favoriteResponseDto); // when then mockMvc.perform(post("/api/favorites/{productId}", 1L)) @@ -117,8 +114,8 @@ void _willSuccess() throws Exception { .build(); given(securityUtil.getCurrentMemberId()).willReturn(1L); - given(favoriteService.getFavorites(any(Long.TYPE), any(Pageable.class))).willReturn( - favoritesResponseDto); + given(favoriteService.getFavorites(any(Long.TYPE), any(Pageable.class))) + .willReturn(favoritesResponseDto); // when then mockMvc.perform(get("/api/favorites") @@ -158,8 +155,8 @@ void _willSuccess() throws Exception { .build(); given(securityUtil.getCurrentMemberId()).willReturn(1L); - given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))).willReturn( - favoriteResponseDto); + given(favoriteService.delete(any(Long.TYPE), any(Long.TYPE))) + .willReturn(favoriteResponseDto); // when then mockMvc.perform(delete("/api/favorites/{productId}", 1L))