-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from MARKETFUBY/feat/event
[차소연] 특가/혜택 목록 조회 구현
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/MARKETFUBY/Event/controller/EventController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package MARKETFUBY.Event.controller; | ||
|
||
import MARKETFUBY.Event.dto.EventDto; | ||
import MARKETFUBY.Event.service.EventService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class EventController { | ||
private final EventService eventService; | ||
|
||
@GetMapping("/market-benefit") | ||
@ResponseStatus(value = HttpStatus.OK) | ||
public List<EventDto> getEventList() { | ||
List<EventDto> eventDtoList = eventService.getEventList(); | ||
return eventDtoList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package MARKETFUBY.Event.dto; | ||
|
||
import MARKETFUBY.Event.domain.Event; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class EventDto{ | ||
private Long eventId; | ||
private String image; | ||
|
||
public static EventDto from(Event event) { | ||
return EventDto.builder() | ||
.eventId(event.getEventId()) | ||
.image(event.getImage()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package MARKETFUBY.Event.service; | ||
|
||
import MARKETFUBY.Event.domain.Event; | ||
import MARKETFUBY.Event.dto.EventDto; | ||
import MARKETFUBY.Event.repository.EventRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
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(); | ||
} | ||
return eventDtoList; | ||
} | ||
} |