Skip to content

Commit

Permalink
Merge pull request #22 from MARKETFUBY/feat/event
Browse files Browse the repository at this point in the history
[차소연] 특가/혜택 목록 조회 오류 해결
  • Loading branch information
Soyeon-Cha authored Nov 23, 2023
2 parents 18c4f8f + 806c158 commit 9674c0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
14 changes: 6 additions & 8 deletions src/main/java/MARKETFUBY/Event/dto/EventDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class EventDto{
private Long eventId;
private String image;
private Long eventId;
private String image;

public static EventDto from(Event event) {
return EventDto.builder()
.eventId(event.getEventId())
.image(event.getImage())
.build();
@Builder
public EventDto(Event event){
this.eventId = event.getEventId();
this.image = event.getImage();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package MARKETFUBY.Event.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import MARKETFUBY.Event.domain.Event;

public interface EventRepository extends JpaRepository<Event, Long> {

List<Event> findAll();
}
18 changes: 9 additions & 9 deletions src/main/java/MARKETFUBY/Event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

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

@Service
@Transactional
Expand All @@ -17,15 +18,14 @@ public class EventService {
private final EventRepository eventRepository;

// 이벤트 목록 조회
@Transactional(readOnly = true)
public List<EventDto> getEventList() {
List<Event> allEvents = eventRepository.findAll();

List<EventDto> eventDtoList = new ArrayList<>();
for (Event event : allEvents) {
Long eventId = event.getEventId();
String image = event.getImage();
}
List<Event> eventList = new Stack<>();
eventList = eventRepository.findAll();
List<EventDto> eventDtoList = eventList.stream()
.map(h -> EventDto.builder()
.event(h)
.build())
.collect(Collectors.toList());
return eventDtoList;
}
}

0 comments on commit 9674c0e

Please sign in to comment.