Skip to content

Commit

Permalink
feat: res dto 반환하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sooyoungh committed Feb 26, 2024
1 parent 69a72e9 commit c815c7c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/main/java/com/hyundai/app/guide/GuideController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,9 +48,9 @@ public ResponseEntity<List<HashtagListResDto>> getGuideByCategory(@PathVariable(

@GetMapping("/hashtag")
@ApiOperation("해시 태그 선택 시, 관련 식당들 조회")
public ResponseEntity<List<Store>> findStoresByHashtags(@RequestParam("hashtagId")int hashtagId) {
public ResponseEntity<List<StoreResDto>> findStoresByHashtags(@RequestParam("hashtagId")int hashtagId) {
log.debug("해시 태그 선택 시, 관련 식당들 조회 => 해시 태그 : " + hashtagId);
List<Store> stores = hashtagService.findStoresByMostSavedHashtags(hashtagId);
List<StoreResDto> stores = hashtagService.findStoresByMostSavedHashtags(hashtagId);
return new ResponseEntity<>(stores, HttpStatus.ACCEPTED);
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -12,5 +12,5 @@
*/
public interface HashtagService {
List<HashtagListResDto> getHashtagAllByGuideType(String guideType);
List<Store> findStoresByMostSavedHashtags(int hashtagId);
List<StoreResDto> findStoresByMostSavedHashtags(int hashtagId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +13,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author 황수영
Expand All @@ -35,20 +37,18 @@ public class HashtagServiceImpl implements HashtagService{
@Override
public List<HashtagListResDto> getHashtagAllByGuideType(String guideType) {
log.debug("분류별 해시태그 조회 분류 : " + guideType);
GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase()); // 식당 분류
GuideType guideTypeEnum = GuideType.valueOf(guideType.toUpperCase());
log.debug("분류별 해시태그 조회 분류 : " + guideTypeEnum);

// TODO: 캐싱 필요!
List<HashtagListResDto> result = new ArrayList<>(); // 식당의 모든 해시태그들 조회
List<HashtagListResDto> result = new ArrayList<>();

for (String category : guideTypeEnum.getCategory()) {
log.debug("분류별 해시태그 조회 => category : " + category);
List<Hashtag> hashtags = hashtagMapper.getHashtagByCategory(category);
HashtagListResDto hashtagListResDto = new HashtagListResDto(category, hashtags);
result.add(hashtagListResDto);
log.debug("분류별 해시태그 조회" + hashtagListResDto);
log.debug("분류별 해시태그 조회 => category : " + category + " : " + hashtagListResDto);
}
// 정렬된 순서대로 조회
return result;
}

Expand All @@ -59,9 +59,10 @@ public List<HashtagListResDto> getHashtagAllByGuideType(String guideType) {
* 해당 해시태그가 가장 많이 저장된 매장들 조회
*/
@Override
public List<Store> findStoresByMostSavedHashtags(int hashtagId) {
public List<StoreResDto> findStoresByMostSavedHashtags(int hashtagId) {
// TODO: 캐싱 필요!
List<Store> stores = storeMapper.getStoresByHashtagId(hashtagId);
// 정렬된 순서대로 조회
return stores;
return stores.stream().map(StoreResDto::of)
.collect(Collectors.toList());
}
}

0 comments on commit c815c7c

Please sign in to comment.