Skip to content

Commit

Permalink
[Fix] story/list 전체 스토리 가져오는 api 로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ceginer authored Aug 22, 2023
1 parent 625054b commit e1be8ba
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main/java/com/example/neoul/service/StoryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,27 @@ public class StoryService {
private final BrandRepository brandRepository;
private final BrandService brandService;

// public List<StoryRes.StoryListRes> getStoryList() {
// List<CategoryV> vCategoryList = categoryVRepository.findAll();
// List<StoryRes.StoryListRes> responseList = new ArrayList<>();
// for (CategoryV vCategory : vCategoryList) {
// Story story = storyRepository.findAllByCategoryV(vCategory).stream().findAny()
// .orElseThrow(() -> new NotFoundException("스토리가 존재하지 않습니다."));
// StoryRes.StoryListRes StoryListRes = StoryRes.StoryListRes.builder()
// .storyId(story.getId())
// .categoryVName(story.getCategoryV().getName())
// .preImg(story.getImg())
// .title(story.getTitle())
// .createdAt(story.getCreatedAt())
// .build();
// responseList.add(StoryListRes);
// }
// return responseList;
// }
public List<StoryRes.StoryListRes> getStoryList() {
List<CategoryV> vCategoryList = categoryVRepository.findAll();
List<StoryRes.StoryListRes> responseList = new ArrayList<>();
for (CategoryV vCategory : vCategoryList) {
Story story = storyRepository.findAllByCategoryV(vCategory).stream().findAny()
.orElseThrow(() -> new NotFoundException("스토리가 존재하지 않습니다."));
List<Story> storyList = storyRepository.findAll();
for (Story story : storyList) {
StoryRes.StoryListRes StoryListRes = StoryRes.StoryListRes.builder()
.storyId(story.getId())
.categoryVName(story.getCategoryV().getName())
Expand Down

0 comments on commit e1be8ba

Please sign in to comment.