From c815c7cb1e0192a5f8bcb4b348e044b04bbe6a69 Mon Sep 17 00:00:00 2001 From: sooyoung Date: Mon, 26 Feb 2024 18:22:41 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20res=20dto=20=EB=B0=98=ED=99=98=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hyundai/app/guide/GuideController.java | 6 +++--- .../app/store/service/HashtagService.java | 4 ++-- .../app/store/service/HashtagServiceImpl.java | 17 +++++++++-------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hyundai/app/guide/GuideController.java b/src/main/java/com/hyundai/app/guide/GuideController.java index 937d100..eb8de67 100644 --- a/src/main/java/com/hyundai/app/guide/GuideController.java +++ b/src/main/java/com/hyundai/app/guide/GuideController.java @@ -2,7 +2,7 @@ import com.hyundai.app.guide.dto.GuideTypeResDto; import com.hyundai.app.guide.dto.HashtagListResDto; -import com.hyundai.app.store.domain.Store; +import com.hyundai.app.store.dto.StoreResDto; import com.hyundai.app.store.service.HashtagService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -48,9 +48,9 @@ public ResponseEntity> getGuideByCategory(@PathVariable( @GetMapping("/hashtag") @ApiOperation("해시 태그 선택 시, 관련 식당들 조회") - public ResponseEntity> findStoresByHashtags(@RequestParam("hashtagId")int hashtagId) { + public ResponseEntity> findStoresByHashtags(@RequestParam("hashtagId")int hashtagId) { log.debug("해시 태그 선택 시, 관련 식당들 조회 => 해시 태그 : " + hashtagId); - List stores = hashtagService.findStoresByMostSavedHashtags(hashtagId); + List stores = hashtagService.findStoresByMostSavedHashtags(hashtagId); return new ResponseEntity<>(stores, HttpStatus.ACCEPTED); } } \ No newline at end of file diff --git a/src/main/java/com/hyundai/app/store/service/HashtagService.java b/src/main/java/com/hyundai/app/store/service/HashtagService.java index 4cfafa4..9c9f125 100644 --- a/src/main/java/com/hyundai/app/store/service/HashtagService.java +++ b/src/main/java/com/hyundai/app/store/service/HashtagService.java @@ -1,7 +1,7 @@ package com.hyundai.app.store.service; import com.hyundai.app.guide.dto.HashtagListResDto; -import com.hyundai.app.store.domain.Store; +import com.hyundai.app.store.dto.StoreResDto; import java.util.List; @@ -12,5 +12,5 @@ */ public interface HashtagService { List getHashtagAllByGuideType(String guideType); - List findStoresByMostSavedHashtags(int hashtagId); + List findStoresByMostSavedHashtags(int hashtagId); } \ 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 2903201..6465831 100644 --- a/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java +++ b/src/main/java/com/hyundai/app/store/service/HashtagServiceImpl.java @@ -4,6 +4,7 @@ import com.hyundai.app.guide.dto.HashtagListResDto; import com.hyundai.app.store.domain.Hashtag; import com.hyundai.app.store.domain.Store; +import com.hyundai.app.store.dto.StoreResDto; import com.hyundai.app.store.mapper.HashtagMapper; import com.hyundai.app.store.mapper.StoreMapper; import lombok.RequiredArgsConstructor; @@ -12,6 +13,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author 황수영 @@ -35,20 +37,18 @@ public class HashtagServiceImpl implements HashtagService{ @Override public List getHashtagAllByGuideType(String guideType) { log.debug("분류별 해시태그 조회 분류 : " + guideType); - GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase()); // 식당 분류 + GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase()); log.debug("분류별 해시태그 조회 분류 : " + guideTypeEnum); // TODO: 캐싱 필요! - List result = new ArrayList<>(); // 식당의 모든 해시태그들 조회 + List result = new ArrayList<>(); for (String category : guideTypeEnum.getCategory()) { - log.debug("분류별 해시태그 조회 => category : " + category); List hashtags = hashtagMapper.getHashtagByCategory(category); HashtagListResDto hashtagListResDto = new HashtagListResDto(category, hashtags); result.add(hashtagListResDto); - log.debug("분류별 해시태그 조회" + hashtagListResDto); + log.debug("분류별 해시태그 조회 => category : " + category + " : " + hashtagListResDto); } - // 정렬된 순서대로 조회 return result; } @@ -59,9 +59,10 @@ public List getHashtagAllByGuideType(String guideType) { * 해당 해시태그가 가장 많이 저장된 매장들 조회 */ @Override - public List findStoresByMostSavedHashtags(int hashtagId) { + public List findStoresByMostSavedHashtags(int hashtagId) { + // TODO: 캐싱 필요! List stores = storeMapper.getStoresByHashtagId(hashtagId); - // 정렬된 순서대로 조회 - return stores; + return stores.stream().map(StoreResDto::of) + .collect(Collectors.toList()); } } \ No newline at end of file