From ccbaccadf1c0140b410ab80c5274223a8dd5d25a Mon Sep 17 00:00:00 2001 From: kyubeom Date: Wed, 10 Jan 2024 22:34:12 +0900 Subject: [PATCH] feature : spotlessApply --- .../everymeal/server/review/entity/Image.java | 5 +-- .../review/repository/ImageRepository.java | 5 +-- .../store/controller/StoreController.java | 3 +- .../server/store/service/StoreService.java | 2 +- .../store/service/StoreServiceImpl.java | 12 +++---- .../store/controller/StoreControllerTest.java | 6 ++-- .../store/service/StoreServiceImplTest.java | 32 +++++++------------ 7 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/main/java/everymeal/server/review/entity/Image.java b/src/main/java/everymeal/server/review/entity/Image.java index a234589..3fdf73d 100644 --- a/src/main/java/everymeal/server/review/entity/Image.java +++ b/src/main/java/everymeal/server/review/entity/Image.java @@ -7,7 +7,6 @@ import jakarta.persistence.GenerationType; import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Builder; @@ -28,9 +27,7 @@ public class Image extends BaseEntity { private Boolean isDeleted; - @ManyToOne - private Review review; - + @ManyToOne private Review review; @Builder public Image(String imageUrl, Review review) { diff --git a/src/main/java/everymeal/server/review/repository/ImageRepository.java b/src/main/java/everymeal/server/review/repository/ImageRepository.java index ba74e7e..b9a8ffa 100644 --- a/src/main/java/everymeal/server/review/repository/ImageRepository.java +++ b/src/main/java/everymeal/server/review/repository/ImageRepository.java @@ -11,7 +11,9 @@ @Repository public interface ImageRepository extends JpaRepository { - @Query(value = """ + @Query( + value = + """ SELECT i FROM images i LEFT JOIN reviews r ON i.review.idx = r.idx and r.store.idx = :storeIdx AND r.isDeleted = false @@ -20,5 +22,4 @@ public interface ImageRepository extends JpaRepository { LIMIT 5 """) List getStoreImages(@Param(value = "storeIdx") Long storeIdx); - } diff --git a/src/main/java/everymeal/server/store/controller/StoreController.java b/src/main/java/everymeal/server/store/controller/StoreController.java index acca8fe..b02c7fc 100644 --- a/src/main/java/everymeal/server/store/controller/StoreController.java +++ b/src/main/java/everymeal/server/store/controller/StoreController.java @@ -92,8 +92,7 @@ public ApplicationResponse> getStores( title = "평점", description = "평점", allowableValues = {"1", "2", "3", "4", "5"}) - Integer grade) - { + Integer grade) { return ApplicationResponse.ok( storeService.getStores( diff --git a/src/main/java/everymeal/server/store/service/StoreService.java b/src/main/java/everymeal/server/store/service/StoreService.java index 62f4557..aaa15ae 100644 --- a/src/main/java/everymeal/server/store/service/StoreService.java +++ b/src/main/java/everymeal/server/store/service/StoreService.java @@ -10,7 +10,7 @@ public interface StoreService { Page getStores( - Long campusIdx, Pageable of, String group, Long userIdx, String order, Integer grade); + Long campusIdx, Pageable of, String group, Long userIdx, String order, Integer grade); StoreGetRes getStore(Long storeIdx, Long userIdx); diff --git a/src/main/java/everymeal/server/store/service/StoreServiceImpl.java b/src/main/java/everymeal/server/store/service/StoreServiceImpl.java index e867aab..9ff186f 100644 --- a/src/main/java/everymeal/server/store/service/StoreServiceImpl.java +++ b/src/main/java/everymeal/server/store/service/StoreServiceImpl.java @@ -41,12 +41,12 @@ public class StoreServiceImpl implements StoreService { @Override public Page getStores( - Long campusIdx, - Pageable pageable, - String group, - Long userIdx, - String order, - Integer grade) { + Long campusIdx, + Pageable pageable, + String group, + Long userIdx, + String order, + Integer grade) { List> stores = storeMapper.getStores( campusIdx, diff --git a/src/test/java/everymeal/server/store/controller/StoreControllerTest.java b/src/test/java/everymeal/server/store/controller/StoreControllerTest.java index f720be4..e5e64c0 100644 --- a/src/test/java/everymeal/server/store/controller/StoreControllerTest.java +++ b/src/test/java/everymeal/server/store/controller/StoreControllerTest.java @@ -202,8 +202,8 @@ void getStoreDetail() throws Exception { // when then mockMvc.perform(get("/api/v1/stores/{storeIdx}", storeIdx)) - .andDo(MockMvcResultHandlers.print()) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.message").value("OK")); + .andDo(MockMvcResultHandlers.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.message").value("OK")); } } diff --git a/src/test/java/everymeal/server/store/service/StoreServiceImplTest.java b/src/test/java/everymeal/server/store/service/StoreServiceImplTest.java index 11cfd0b..ab18b08 100644 --- a/src/test/java/everymeal/server/store/service/StoreServiceImplTest.java +++ b/src/test/java/everymeal/server/store/service/StoreServiceImplTest.java @@ -50,8 +50,8 @@ void tearDown() { storeRepository.deleteAll(); universityRepository.deleteAll(); userRepository.deleteAll(); -// imageRepository.deleteAll(); -// reviewRepository.deleteAll(); + // imageRepository.deleteAll(); + // reviewRepository.deleteAll(); } @DisplayName("캠퍼스 기준 식당 가져오기") @@ -262,14 +262,14 @@ void getStoreDetail() { Review review = createReviewEntity(store, getUser(university, 1)); reviewRepository.save(review); - List images = List.of( - createImageEntity("1",review), - createImageEntity("2",review), - createImageEntity("3",review), - createImageEntity("4",review), - createImageEntity("5",review), - createImageEntity("6",review) - ); + List images = + List.of( + createImageEntity("1", review), + createImageEntity("2", review), + createImageEntity("3", review), + createImageEntity("4", review), + createImageEntity("5", review), + createImageEntity("6", review)); imageRepository.saveAll(images); entityManager.clear(); @@ -283,19 +283,11 @@ void getStoreDetail() { } private Image createImageEntity(String urlNumber, Review review) { - return Image.builder() - .imageUrl("url"+urlNumber) - .review(review) - .build(); + return Image.builder().imageUrl("url" + urlNumber).review(review).build(); } private Review createReviewEntity(Store store, User user) { - return Review.builder() - .store(store) - .user(user) - .content("content") - .grade(0) - .build(); + return Review.builder().store(store).user(user).content("content").grade(0).build(); } private Like createLikeEntity(Store store, User user) {