From f85797f276098fd1c2f7f2e948264547db080517 Mon Sep 17 00:00:00 2001 From: sooyoung Date: Sat, 9 Mar 2024 08:29:16 +0900 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=EB=A6=AC=EB=B7=B0=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/event/service/EventService.java | 40 +++++++++++++++++-- .../com/hyundai/app/store/domain/Hashtag.java | 7 ++++ .../com/hyundai/app/store/domain/Image.java | 23 +++++++++++ .../com/hyundai/app/store/domain/Review.java | 21 +++++++++- .../app/store/domain/ReviewHashtag.java | 19 +++++++++ .../hyundai/app/store/dto/ReviewResDto.java | 7 +++- .../app/store/mapper/HashtagMapper.java | 4 ++ .../hyundai/app/store/mapper/StoreMapper.java | 4 ++ .../app/store/service/StoreServiceImpl.java | 20 ++++++---- src/main/resources/mapper/HashtagMapper.xml | 24 ++++++++++- src/main/resources/mapper/StoreMapper.xml | 30 ++++++++++++++ 11 files changed, 185 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/hyundai/app/store/domain/Image.java create mode 100644 src/main/java/com/hyundai/app/store/domain/ReviewHashtag.java diff --git a/src/main/java/com/hyundai/app/event/service/EventService.java b/src/main/java/com/hyundai/app/event/service/EventService.java index 7cc78c4..68f23eb 100644 --- a/src/main/java/com/hyundai/app/event/service/EventService.java +++ b/src/main/java/com/hyundai/app/event/service/EventService.java @@ -21,9 +21,10 @@ import java.util.List; /** + * The type Event service. + * * @author 엄상은 - * @since 2024/02/18 - * 사용자용 + 어드민용 이벤트 서비스 + * @since 2024 /02/18 사용자용 + 어드민용 이벤트 서비스 */ @Log4j @RequiredArgsConstructor @@ -35,6 +36,10 @@ public class EventService { private final MemberCouponMapper memberCouponMapper; private final CouponMapper couponMapper; + /** + * @author + * @since 2024 /02/ (설명) + */ public List findCurrentEventByEventType(String memberId) { List eventDetailResDtoList = eventMapper.findCurrentEventByEventType(memberId); @@ -47,6 +52,10 @@ public List findCurrentEventByEventType(String memberId) { return eventDetailResDtoList; } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventListResDto findEventList(int storeId, int page, int size) { IdWithCriteria idWithCriteria = IdWithCriteria.of(storeId, page, size); List eventDetailResDtoList = eventMapper.findEventList(idWithCriteria); @@ -61,6 +70,10 @@ public EventListResDto findEventList(int storeId, int page, int size) { return eventListResDto; } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventDetailResDto find(int storeId, int eventId) { EventDetailResDto eventDetailResDto = findEventAndValidate(storeId, eventId); List eventActiveTimeZoneDto = findEventActiveTime(eventId); @@ -68,6 +81,10 @@ public EventDetailResDto find(int storeId, int eventId) { return eventDetailResDto; } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventDetailResDto findEventAndValidate(int storeId, int eventId) { EventDetailResDto eventDetailResDto = eventMapper.findById(eventId); if (eventDetailResDto == null) { @@ -97,6 +114,10 @@ private List findEventActiveTime(int eventId) { return eventActiveTimeZoneDto; } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventDetailResDto save(int storeId, EventSaveReqDto eventSaveReqDto) { int eventId = saveEvent(storeId, eventSaveReqDto); saveEventActiveTime(eventId, eventSaveReqDto); @@ -118,6 +139,10 @@ private void saveEventActiveTime(int eventId, EventSaveReqDto eventSaveReqDto) { }); } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventSaveReqDto update(int storeId, int eventId, EventSaveReqDto eventSaveReqDto) { findEventAndValidate(storeId, eventId); eventSaveReqDto.setId(eventId); @@ -125,12 +150,20 @@ public EventSaveReqDto update(int storeId, int eventId, EventSaveReqDto eventSav return eventSaveReqDto; } + /** + * @author + * @since 2024 /02/ (설명) + */ public Void delete(int storeId, int eventId) { findEventAndValidate(storeId, eventId); eventMapper.delete(eventId); return null; } + /** + * @author + * @since 2024 /02/ (설명) + */ public EventParticipateResDto participateEvent(String memberId, int eventId) { EventDetailResDto eventDetailResDto = findAvailableEvent(eventId); EventParticipateResDto eventVisitResDto = EventParticipateResDto.of(eventDetailResDto); @@ -184,12 +217,13 @@ public EventDetailResDto getRandomSpotDetail(String eventType) { return eventDetailResDto; } + + /** * @author 최성혁 * @since 2024/02/27 * 특정 이벤트에 참여중인 회원 목록 */ - public List findEventParticipants(int eventId, int id) { List participants = memberEventMapper.getMemberEventDetails(eventId); diff --git a/src/main/java/com/hyundai/app/store/domain/Hashtag.java b/src/main/java/com/hyundai/app/store/domain/Hashtag.java index a633bc9..ec776bc 100644 --- a/src/main/java/com/hyundai/app/store/domain/Hashtag.java +++ b/src/main/java/com/hyundai/app/store/domain/Hashtag.java @@ -17,4 +17,11 @@ public class Hashtag { private int id; private String name; private String category; + + public static Hashtag from(int id) { + Hashtag hashtag = new Hashtag(); + hashtag.id = id; + return hashtag; + } + } diff --git a/src/main/java/com/hyundai/app/store/domain/Image.java b/src/main/java/com/hyundai/app/store/domain/Image.java new file mode 100644 index 0000000..e6f5984 --- /dev/null +++ b/src/main/java/com/hyundai/app/store/domain/Image.java @@ -0,0 +1,23 @@ +package com.hyundai.app.store.domain; + +import lombok.*; + +/** + * @author 황수영 + * @since 2024/03/04 + * (설명) + */ + +@Getter +@Builder +@ToString +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Image { + + private int id; + private String imgUrl; + private int storeId; + private String memberId; + private String reviewId; +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/domain/Review.java b/src/main/java/com/hyundai/app/store/domain/Review.java index 3ca4251..b83f7cb 100644 --- a/src/main/java/com/hyundai/app/store/domain/Review.java +++ b/src/main/java/com/hyundai/app/store/domain/Review.java @@ -3,7 +3,9 @@ import com.hyundai.app.common.entity.BaseEntity; import com.hyundai.app.store.dto.ReviewReqDto; import lombok.*; +import lombok.extern.log4j.Log4j; +import java.util.ArrayList; import java.util.List; /** @@ -15,6 +17,7 @@ @Builder @ToString @AllArgsConstructor +@Log4j @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Review extends BaseEntity { @@ -24,16 +27,30 @@ public class Review extends BaseEntity { private int isDeleted; private int score; private String content; - private List hashtags; + private List hashtags; + private List imageList; public static Review of(String id, ReviewReqDto reviewReqDto, int storeId, String memberId) { + log.debug("Review id " + id); + List hashtags = new ArrayList<>(); + for (int hashtagId : reviewReqDto.getHashtagIds()) { + hashtags.add(Hashtag.from(hashtagId)); + } return Review.builder() .id(id) .score(reviewReqDto.getScore()) .content(reviewReqDto.getContent()) .memberId(memberId) .storeId(storeId) - .hashtags(reviewReqDto.getHashtagIds()) + .hashtags(hashtags) .build(); } + + public void updateImages(List imageList) { + this.imageList = imageList; + } + + public void updateHashtags(List hashtags) { + this.hashtags = hashtags; + } } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/domain/ReviewHashtag.java b/src/main/java/com/hyundai/app/store/domain/ReviewHashtag.java new file mode 100644 index 0000000..120fc50 --- /dev/null +++ b/src/main/java/com/hyundai/app/store/domain/ReviewHashtag.java @@ -0,0 +1,19 @@ +package com.hyundai.app.store.domain; + +import lombok.*; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +@Getter +@Builder +@ToString +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class ReviewHashtag { + private int id; + private int reviewId; + private int storeId; +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java b/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java index a51b321..b3ad2c3 100644 --- a/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java +++ b/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java @@ -1,5 +1,7 @@ package com.hyundai.app.store.dto; +import com.hyundai.app.store.domain.Hashtag; +import com.hyundai.app.store.domain.Image; import com.hyundai.app.store.domain.Review; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,12 +23,15 @@ public class ReviewResDto { private String id; private int score; private String content; - private List hashtags; + private List hashtags; + private List images; public static ReviewResDto of(Review review) { return ReviewResDto.builder() .id(review.getId()) .score(review.getScore()) .content(review.getContent()) + .images(review.getImageList()) + .hashtags(review.getHashtags()) .build(); } } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/mapper/HashtagMapper.java b/src/main/java/com/hyundai/app/store/mapper/HashtagMapper.java index 848cd9b..ec8bbd4 100644 --- a/src/main/java/com/hyundai/app/store/mapper/HashtagMapper.java +++ b/src/main/java/com/hyundai/app/store/mapper/HashtagMapper.java @@ -18,4 +18,8 @@ public interface HashtagMapper { StoreHashtag getStoreHashtag(@Param("storeId") int storeId, @Param("hashtagId") int hashtagId); void updateStoreHashtag(@Param("storeId") int storeId, @Param("hashtagId") int hashtagId); List getHashtagByCategory(@Param("category") String category); + void createReviewHashtag(@Param("reviewId") String reviewId, @Param("hashtagId") int hashtagId); + List getHashtagByReviewId(@Param("reviewId") String reviewId); + + } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/mapper/StoreMapper.java b/src/main/java/com/hyundai/app/store/mapper/StoreMapper.java index 6fef33e..fe80d02 100644 --- a/src/main/java/com/hyundai/app/store/mapper/StoreMapper.java +++ b/src/main/java/com/hyundai/app/store/mapper/StoreMapper.java @@ -1,6 +1,7 @@ package com.hyundai.app.store.mapper; import com.hyundai.app.store.domain.Hashtag; +import com.hyundai.app.store.domain.Image; import com.hyundai.app.store.domain.Review; import com.hyundai.app.store.domain.Store; import org.apache.ibatis.annotations.Param; @@ -22,4 +23,7 @@ public interface StoreMapper { List getStoresByHashtagId(@Param("hashtagId") int hashtagId); void saveReviewImage(@Param("reviewId") String reviewId, @Param("memberId") String memberId , @Param("storeId") int storeId, @Param("image") String image); + + List getImageByReviewId(@Param("reviewId") String reviewId); + } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java b/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java index d3910d5..9821520 100644 --- a/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java +++ b/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java @@ -1,8 +1,8 @@ package com.hyundai.app.store.service; import com.hyundai.app.exception.AdventureOfHeendyException; -import com.hyundai.app.member.service.AwsS3Config; import com.hyundai.app.store.domain.Hashtag; +import com.hyundai.app.store.domain.Image; import com.hyundai.app.store.domain.Review; import com.hyundai.app.store.domain.Store; import com.hyundai.app.store.dto.ReviewReqDto; @@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import java.io.File; import java.util.List; import java.util.UUID; @@ -41,7 +40,7 @@ public class StoreServiceImpl implements StoreService { /** * @author 황수영 * @since 2024/02/14 - * 매장 상세 정보/해시태그/이미지/리뷰 조회 + * 매장 상세 정보/해시태그/이미지/리뷰(이미지 포함) 조회 */ @Override public StoreResDto getStoreDetail(int storeId) { @@ -55,7 +54,14 @@ public StoreResDto getStoreDetail(int storeId) { log.debug("가장 많이 선택된 해시태그들 5개 조회 : " + popularHashtags.toString()); List reviews = storeMapper.getReviews(storeId); - log.debug("해당 매장의 전체 리뷰 조회 : " + reviews.toString()); + for (Review review : reviews) { + List images = storeMapper.getImageByReviewId(review.getId()); + review.updateImages(images); + + List hashtags = hashtagMapper.getHashtagByReviewId(review.getId()); + review.updateHashtags(hashtags); + } + log.debug("해당 매장의 전체 리뷰 조회 : " + reviews); StoreResDto storeResDto = StoreResDto.of(store); storeResDto.updatePopularHashtags(popularHashtags); @@ -75,6 +81,9 @@ public void createReview(int storeId, String memberId, ReviewReqDto reviewReqDto String reviewId = UUID.randomUUID().toString(); Review review = Review.of(reviewId, reviewReqDto, storeId, memberId); storeMapper.saveReview(review); + for (Hashtag hashtag : review.getHashtags()) { + hashtagMapper.createReviewHashtag(review.getId(), hashtag.getId()); + } log.debug("리뷰 작성" + review); // 이미지 추가 @@ -87,7 +96,6 @@ public void createReview(int storeId, String memberId, ReviewReqDto reviewReqDto // 해시 태그 추가 createStoreHashtag(storeId, reviewReqDto.getHashtagIds()); - // TODO: 리뷰별 해시태그 추가 //평점 업데이트 double newAvgScore = calcAvgScore(storeId, reviewReqDto.getScore()); @@ -95,8 +103,6 @@ public void createReview(int storeId, String memberId, ReviewReqDto reviewReqDto storeMapper.updateReviewCount(storeId); } - - /** * @author 황수영 * @since 2024/02/14 diff --git a/src/main/resources/mapper/HashtagMapper.xml b/src/main/resources/mapper/HashtagMapper.xml index d9904d8..f22e474 100644 --- a/src/main/resources/mapper/HashtagMapper.xml +++ b/src/main/resources/mapper/HashtagMapper.xml @@ -31,6 +31,19 @@ ) + + INSERT INTO review_hashtag ( + id + , hashtag_id + , review_id + ) + VALUES ( + review_hashtag_id_seq.nextval + , #{hashtagId} + , #{reviewId} + ) + + SELECT id AS id - , name AS name + , name AS name FROM hashtag WHERE category = #{category} + + \ No newline at end of file diff --git a/src/main/resources/mapper/StoreMapper.xml b/src/main/resources/mapper/StoreMapper.xml index 33fe3cb..4db4640 100644 --- a/src/main/resources/mapper/StoreMapper.xml +++ b/src/main/resources/mapper/StoreMapper.xml @@ -34,6 +34,24 @@ WHERE store_id = #{storeId} + + + + + + + + + + + + + + + + + + + SELECT image.id AS id + , review.id AS reviewId + , review.member_id AS memberId + , review.store_id AS storeId + , image.img_url AS imgUrl + FROM review, image + WHERE review.id = image.review_id + AND review.id = #{reviewId} + + \ No newline at end of file From d2ee7ab7782bb66c90aefd6423095cda17bac6c0 Mon Sep 17 00:00:00 2001 From: sooyoung Date: Sat, 9 Mar 2024 10:15:26 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=EC=B5=9C=EC=8B=A0=EC=88=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/hyundai/app/store/dto/ReviewResDto.java | 3 +++ src/main/resources/mapper/StoreMapper.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java b/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java index b3ad2c3..f298437 100644 --- a/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java +++ b/src/main/java/com/hyundai/app/store/dto/ReviewResDto.java @@ -9,6 +9,7 @@ import lombok.NoArgsConstructor; import java.util.List; +import java.time.LocalDate; /** * @author 황수영 @@ -23,6 +24,7 @@ public class ReviewResDto { private String id; private int score; private String content; + private LocalDate createdAt; private List hashtags; private List images; public static ReviewResDto of(Review review) { @@ -32,6 +34,7 @@ public static ReviewResDto of(Review review) { .content(review.getContent()) .images(review.getImageList()) .hashtags(review.getHashtags()) + .createdAt(review.getCreatedAt()) .build(); } } \ No newline at end of file diff --git a/src/main/resources/mapper/StoreMapper.xml b/src/main/resources/mapper/StoreMapper.xml index 4db4640..22a03b2 100644 --- a/src/main/resources/mapper/StoreMapper.xml +++ b/src/main/resources/mapper/StoreMapper.xml @@ -32,6 +32,7 @@ , content FROM review WHERE store_id = #{storeId} + ORDER BY created_at DESC From f208c295739c484eddfd43d04d4033fb64f1b40c Mon Sep 17 00:00:00 2001 From: sooyoung Date: Mon, 11 Mar 2024 18:08:22 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20=EC=B1=97=EB=B4=87=20=ED=9D=B0?= =?UTF-8?q?=EB=94=94=20=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hyundai/app/guide/GuideController.java | 7 +- .../com/hyundai/app/guide/GuideMapper.java | 17 +++++ .../com/hyundai/app/guide/GuideService.java | 66 +++++++++++++++++++ .../java/com/hyundai/app/guide/GuideType.java | 12 +++- .../com/hyundai/app/guide/HashtagType.java | 21 ++++++ .../com/hyundai/app/guide/domain/Guide.java | 22 +++++++ .../app/guide/domain/HashtagCategory.java | 18 +++++ .../app/guide/dto/HashtagListResDto.java | 1 + .../app/store/enumType/HashTagCategory.java | 14 ---- .../app/store/service/HashtagServiceImpl.java | 15 ++++- src/main/resources/mapper/GuideMapper.xml | 22 +++++++ 11 files changed, 195 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/hyundai/app/guide/GuideMapper.java create mode 100644 src/main/java/com/hyundai/app/guide/GuideService.java create mode 100644 src/main/java/com/hyundai/app/guide/HashtagType.java create mode 100644 src/main/java/com/hyundai/app/guide/domain/Guide.java create mode 100644 src/main/java/com/hyundai/app/guide/domain/HashtagCategory.java delete mode 100644 src/main/java/com/hyundai/app/store/enumType/HashTagCategory.java create mode 100644 src/main/resources/mapper/GuideMapper.xml diff --git a/src/main/java/com/hyundai/app/guide/GuideController.java b/src/main/java/com/hyundai/app/guide/GuideController.java index fc165e2..abdfec3 100644 --- a/src/main/java/com/hyundai/app/guide/GuideController.java +++ b/src/main/java/com/hyundai/app/guide/GuideController.java @@ -32,10 +32,13 @@ public class GuideController { @Qualifier("hashtagServiceImpl") private HashtagService hashtagService; + @Autowired + private GuideService guideService; + @GetMapping @ApiOperation("전체 가이드 조회") public ResponseEntity> getGuideAll() { - List guideTypeList = GuideType.getGuideResDtoAll(); + List guideTypeList = guideService.getGuideAll(); log.debug("전체 가이드 조회 : " + guideTypeList); return new ResponseEntity<>(guideTypeList, HttpStatus.ACCEPTED); } @@ -44,7 +47,7 @@ public ResponseEntity> getGuideAll() { @ApiOperation("분류별 해시태그 조회 - 해당 분류의 모든 해시태그 조회하기 - 식당/쇼핑 매장") public ResponseEntity> getGuideByCategory(@PathVariable("guideType") String guideType) { log.debug("분류별 해시태그 조회 => guideType : " + guideType); - List hashtagListResDto = hashtagService.getHashtagAllByGuideType(guideType); + List hashtagListResDto = guideService.getHashtagCategoryAll(guideType); return new ResponseEntity<>(hashtagListResDto, HttpStatus.ACCEPTED); } diff --git a/src/main/java/com/hyundai/app/guide/GuideMapper.java b/src/main/java/com/hyundai/app/guide/GuideMapper.java new file mode 100644 index 0000000..196ad0e --- /dev/null +++ b/src/main/java/com/hyundai/app/guide/GuideMapper.java @@ -0,0 +1,17 @@ +package com.hyundai.app.guide; + +import com.hyundai.app.guide.domain.Guide; +import com.hyundai.app.guide.domain.HashtagCategory; + +import java.util.List; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +public interface GuideMapper { + + List getGuideAll(); + List getHashtagCategoryAll(); +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/guide/GuideService.java b/src/main/java/com/hyundai/app/guide/GuideService.java new file mode 100644 index 0000000..4a66001 --- /dev/null +++ b/src/main/java/com/hyundai/app/guide/GuideService.java @@ -0,0 +1,66 @@ +package com.hyundai.app.guide; + +import com.hyundai.app.guide.domain.Guide; +import com.hyundai.app.guide.domain.HashtagCategory; +import com.hyundai.app.guide.dto.GuideTypeResDto; +import com.hyundai.app.guide.dto.HashtagListResDto; +import com.hyundai.app.store.domain.Hashtag; +import com.hyundai.app.store.mapper.HashtagMapper; +import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +@Log4j +@Service +@RequiredArgsConstructor +public class GuideService { + + private final GuideMapper guideMapper; + private final HashtagMapper hashtagMapper; + + public List getGuideAll() { + List guideList = guideMapper.getGuideAll(); + List guideTypeList = GuideType.of(guideList); + log.debug("GuideService 전체 가이드 조회 : " + guideTypeList); + return guideTypeList; + } + + /** + * @author 황수영 + * @since 2024/02/26 + * 분류별 해시태그 전체 조회 + */ + public List getHashtagCategoryAll(String guideType) { + log.debug("분류별 해시태그 조회 분류 : " + guideType); + GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase()); + log.debug("분류별 해시태그 조회 분류 : " + guideTypeEnum); + + List hashtagCategories = guideMapper.getHashtagCategoryAll(); + + // TODO: 캐싱 필요! + List result = new ArrayList<>(); + + for (String category : guideTypeEnum.getHashtagType()) { + List hashtags = hashtagMapper.getHashtagByCategory(category); + String korean = hashtagCategories.stream() + .filter(h -> h.getTitle().equals(category)) + .findFirst() + .map(HashtagCategory::getKorean) + .orElseThrow(NoSuchElementException::new); + // 한글로 변경 + HashtagListResDto hashtagListResDto = new HashtagListResDto(korean, hashtags); + result.add(hashtagListResDto); + log.debug("분류별 해시태그 조회 => category : " + category + " : " + hashtagListResDto); + } + return result; + } +} diff --git a/src/main/java/com/hyundai/app/guide/GuideType.java b/src/main/java/com/hyundai/app/guide/GuideType.java index 74d39ef..6d4f8c6 100644 --- a/src/main/java/com/hyundai/app/guide/GuideType.java +++ b/src/main/java/com/hyundai/app/guide/GuideType.java @@ -1,5 +1,6 @@ package com.hyundai.app.guide; +import com.hyundai.app.guide.domain.Guide; import com.hyundai.app.guide.dto.GuideTypeResDto; import lombok.AllArgsConstructor; import lombok.Getter; @@ -24,11 +25,18 @@ public enum GuideType { private final int id; private final String korean; - private final List category; + private final List hashtagType; public static List getGuideResDtoAll() { return Arrays.stream(GuideType.values()) - .map(g -> new GuideTypeResDto(g, g.korean, g.category)) + .map(g -> new GuideTypeResDto(g, g.korean, g.hashtagType)) + .collect(Collectors.toList()); + } + + public static List of(List guides) { + + return guides.stream() + .map(g -> new GuideTypeResDto(GuideType.valueOf(g.getGuideType()), g.getKorean(), GuideType.valueOf(g.getGuideType()).getHashtagType())) .collect(Collectors.toList()); } } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/guide/HashtagType.java b/src/main/java/com/hyundai/app/guide/HashtagType.java new file mode 100644 index 0000000..b6e812c --- /dev/null +++ b/src/main/java/com/hyundai/app/guide/HashtagType.java @@ -0,0 +1,21 @@ +package com.hyundai.app.guide; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +@Getter +@AllArgsConstructor +public enum HashtagType { + + FOOD(10000, "음식"), + ATMOSPHERE(10001, "분위기"), + ETC(10002, "가격"); + + private final int id; + private final String korean; +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/guide/domain/Guide.java b/src/main/java/com/hyundai/app/guide/domain/Guide.java new file mode 100644 index 0000000..9418ab4 --- /dev/null +++ b/src/main/java/com/hyundai/app/guide/domain/Guide.java @@ -0,0 +1,22 @@ +package com.hyundai.app.guide.domain; + +import lombok.*; + +import java.util.List; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +@Getter +@Builder +@ToString +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Guide { + + private int id; + private String korean; + private String guideType; +} diff --git a/src/main/java/com/hyundai/app/guide/domain/HashtagCategory.java b/src/main/java/com/hyundai/app/guide/domain/HashtagCategory.java new file mode 100644 index 0000000..c2e52d2 --- /dev/null +++ b/src/main/java/com/hyundai/app/guide/domain/HashtagCategory.java @@ -0,0 +1,18 @@ +package com.hyundai.app.guide.domain; + +import lombok.*; + +/** + * @author 황수영 + * @since 2024/03/09 + * (설명) + */ +@Getter +@Builder +@ToString +@AllArgsConstructor +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class HashtagCategory { + private String title; + private String korean; +} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/guide/dto/HashtagListResDto.java b/src/main/java/com/hyundai/app/guide/dto/HashtagListResDto.java index 65498de..db509d9 100644 --- a/src/main/java/com/hyundai/app/guide/dto/HashtagListResDto.java +++ b/src/main/java/com/hyundai/app/guide/dto/HashtagListResDto.java @@ -16,5 +16,6 @@ public class HashtagListResDto { private String title; + // private String korean; private List hashtags; } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/enumType/HashTagCategory.java b/src/main/java/com/hyundai/app/store/enumType/HashTagCategory.java deleted file mode 100644 index 8b1bc61..0000000 --- a/src/main/java/com/hyundai/app/store/enumType/HashTagCategory.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hyundai.app.store.enumType; - -import lombok.Getter; - -/** - * @author 황수영 - * @since 2024/02/13 - * 해시태그 카테고리 목록 enum - */ - -@Getter -public enum HashTagCategory { - FOOD, PRICE, INTERIOR, ELSE; -} \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java b/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java index 6465831..12be07e 100644 --- a/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java +++ b/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java @@ -1,6 +1,8 @@ package com.hyundai.app.store.service; +import com.hyundai.app.guide.GuideMapper; import com.hyundai.app.guide.GuideType; +import com.hyundai.app.guide.domain.HashtagCategory; import com.hyundai.app.guide.dto.HashtagListResDto; import com.hyundai.app.store.domain.Hashtag; import com.hyundai.app.store.domain.Store; @@ -13,6 +15,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.NoSuchElementException; import java.util.stream.Collectors; /** @@ -27,6 +30,7 @@ public class HashtagServiceImpl implements HashtagService{ private final StoreMapper storeMapper; private final HashtagMapper hashtagMapper; + private final GuideMapper guideMapper; /** @@ -40,12 +44,19 @@ public List getHashtagAllByGuideType(String guideType) { GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase()); log.debug("분류별 해시태그 조회 분류 : " + guideTypeEnum); + List hashtagCategories = guideMapper.getHashtagCategoryAll(); + // TODO: 캐싱 필요! List result = new ArrayList<>(); - for (String category : guideTypeEnum.getCategory()) { + for (String category : guideTypeEnum.getHashtagType()) { List hashtags = hashtagMapper.getHashtagByCategory(category); - HashtagListResDto hashtagListResDto = new HashtagListResDto(category, hashtags); + String korean = hashtagCategories.stream() + .filter(h -> h.getTitle().equals(category)) + .findFirst() + .map(HashtagCategory::getKorean) + .orElseThrow(NoSuchElementException::new); + HashtagListResDto hashtagListResDto = new HashtagListResDto(korean, hashtags); result.add(hashtagListResDto); log.debug("분류별 해시태그 조회 => category : " + category + " : " + hashtagListResDto); } diff --git a/src/main/resources/mapper/GuideMapper.xml b/src/main/resources/mapper/GuideMapper.xml new file mode 100644 index 0000000..087a4b7 --- /dev/null +++ b/src/main/resources/mapper/GuideMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + \ No newline at end of file From e5918abf68acf485c2a735936aa0b664b1716174 Mon Sep 17 00:00:00 2001 From: sooyoung Date: Mon, 11 Mar 2024 18:09:06 +0900 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=95=88=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/store/controller/StoreController.java | 3 +++ .../java/com/hyundai/app/store/domain/Review.java | 6 ++++-- .../hyundai/app/store/service/StoreServiceImpl.java | 12 +++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hyundai/app/store/controller/StoreController.java b/src/main/java/com/hyundai/app/store/controller/StoreController.java index ff0b45c..b283d46 100644 --- a/src/main/java/com/hyundai/app/store/controller/StoreController.java +++ b/src/main/java/com/hyundai/app/store/controller/StoreController.java @@ -6,6 +6,7 @@ import com.hyundai.app.store.service.StoreService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.extern.log4j.Log4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; @@ -22,6 +23,7 @@ * @since 2024/02/13 * 매장 관련 기능 컨트롤러 */ +@Log4j @Api("매장 관련 API") @RestController @RequestMapping("/api/v1/stores") @@ -57,6 +59,7 @@ public ResponseEntity createReview( @RequestPart(value = "imageList", required = false) List imageList, @ApiIgnore @MemberId String memberId ) { + log.debug("매장 리뷰 작성 API" + reviewReqDto.toString()); storeService.createReview(storeId, memberId, reviewReqDto, imageList); return new ResponseEntity<>(HttpStatus.ACCEPTED); } diff --git a/src/main/java/com/hyundai/app/store/domain/Review.java b/src/main/java/com/hyundai/app/store/domain/Review.java index b83f7cb..9e0c8ac 100644 --- a/src/main/java/com/hyundai/app/store/domain/Review.java +++ b/src/main/java/com/hyundai/app/store/domain/Review.java @@ -33,8 +33,10 @@ public class Review extends BaseEntity { public static Review of(String id, ReviewReqDto reviewReqDto, int storeId, String memberId) { log.debug("Review id " + id); List hashtags = new ArrayList<>(); - for (int hashtagId : reviewReqDto.getHashtagIds()) { - hashtags.add(Hashtag.from(hashtagId)); + if (reviewReqDto.getHashtagIds() != null) { + for (int hashtagId : reviewReqDto.getHashtagIds()) { + hashtags.add(Hashtag.from(hashtagId)); + } } return Review.builder() .id(id) diff --git a/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java b/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java index 9821520..59b67ca 100644 --- a/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java +++ b/src/main/java/com/hyundai/app/store/service/StoreServiceImpl.java @@ -87,11 +87,13 @@ public void createReview(int storeId, String memberId, ReviewReqDto reviewReqDto log.debug("리뷰 작성" + review); // 이미지 추가 - List imageUrlList = s3ImageUploadService.uploadReviewImages(imagelist); - for (String imageUrl : imageUrlList) { - log.debug("이미지 추가 reviewId : " + reviewId + ", memberId : " + memberId - + ", storeId : " + storeId + ", imageUrl : " + imageUrl); - storeMapper.saveReviewImage(reviewId, memberId, storeId, imageUrl); + if (imagelist != null) { + List imageUrlList = s3ImageUploadService.uploadReviewImages(imagelist); + for (String imageUrl : imageUrlList) { + log.debug("이미지 추가 reviewId : " + reviewId + ", memberId : " + memberId + + ", storeId : " + storeId + ", imageUrl : " + imageUrl); + storeMapper.saveReviewImage(reviewId, memberId, storeId, imageUrl); + } } // 해시 태그 추가