Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] story/list 전체 스토리 가져오는 api 로 수정 #64

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading