From c38c49d2fb180d33b0c69de6e0a5d52173e94b79 Mon Sep 17 00:00:00 2001 From: tori Date: Sat, 2 Mar 2024 15:23:57 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9C=A0=EC=A0=80=EC=9A=A9=20=EC=BF=A0?= =?UTF-8?q?=ED=8F=B0,=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EC=8B=9C=20=EC=95=84=EC=9D=B4=EC=BD=98=20=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hyundai/app/coupon/domain/Coupon.java | 1 + .../app/event/controller/EventController.java | 5 +++-- .../com/hyundai/app/event/domain/Event.java | 1 + .../app/event/dto/EventDetailResDto.java | 1 + .../hyundai/app/event/mapper/EventMapper.java | 2 +- .../hyundai/app/event/service/EventService.java | 17 ++++++++--------- src/main/resources/mapper/CouponMapper.xml | 1 + src/main/resources/mapper/EventMapper.xml | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/hyundai/app/coupon/domain/Coupon.java b/src/main/java/com/hyundai/app/coupon/domain/Coupon.java index 00cb509..24d478f 100644 --- a/src/main/java/com/hyundai/app/coupon/domain/Coupon.java +++ b/src/main/java/com/hyundai/app/coupon/domain/Coupon.java @@ -23,6 +23,7 @@ public class Coupon { private CouponType couponType; private String content; private String code; + private String iconUrl; @JsonFormat(pattern = "yyyy-MM-dd") private LocalDate startedAt; @JsonFormat(pattern = "yyyy-MM-dd") diff --git a/src/main/java/com/hyundai/app/event/controller/EventController.java b/src/main/java/com/hyundai/app/event/controller/EventController.java index 2ffa1fd..b37a516 100644 --- a/src/main/java/com/hyundai/app/event/controller/EventController.java +++ b/src/main/java/com/hyundai/app/event/controller/EventController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; +import java.util.List; import java.util.Random; /** @@ -30,8 +31,8 @@ public class EventController { private static final Random random = new Random(); @GetMapping - @ApiOperation("유저용 현재 열린 이벤트 조회 API") - public AdventureOfHeendyResponse findCurrentEventByEventType(@RequestParam EventType eventType) { + @ApiOperation("유저용 현재 열린 이벤트 전체 조회 API") + public AdventureOfHeendyResponse> findCurrentEventByEventType(@RequestParam EventType eventType) { return AdventureOfHeendyResponse.success("이벤트 목록을 가져왔습니다.", eventService.findCurrentEventByEventType(eventType)); } diff --git a/src/main/java/com/hyundai/app/event/domain/Event.java b/src/main/java/com/hyundai/app/event/domain/Event.java index f8c1152..41bf5e4 100644 --- a/src/main/java/com/hyundai/app/event/domain/Event.java +++ b/src/main/java/com/hyundai/app/event/domain/Event.java @@ -24,4 +24,5 @@ public class Event extends BaseEntity { private String reward; private int isDeleted; private int storeId; + private String iconUrl; } diff --git a/src/main/java/com/hyundai/app/event/dto/EventDetailResDto.java b/src/main/java/com/hyundai/app/event/dto/EventDetailResDto.java index 38aa43c..00b43fb 100644 --- a/src/main/java/com/hyundai/app/event/dto/EventDetailResDto.java +++ b/src/main/java/com/hyundai/app/event/dto/EventDetailResDto.java @@ -33,6 +33,7 @@ public class EventDetailResDto { private int maxCount; private int visitedCount; private int couponId; + private String iconUrl; private List eventActiveTimeZoneDto; public void setActiveTimeList(List eventActiveTimeZoneDto) { diff --git a/src/main/java/com/hyundai/app/event/mapper/EventMapper.java b/src/main/java/com/hyundai/app/event/mapper/EventMapper.java index 482fee6..8a15d43 100644 --- a/src/main/java/com/hyundai/app/event/mapper/EventMapper.java +++ b/src/main/java/com/hyundai/app/event/mapper/EventMapper.java @@ -15,7 +15,7 @@ */ @Mapper public interface EventMapper { - EventDetailResDto findCurrentEventByEventType(EventType eventType); + List findCurrentEventByEventType(EventType eventType); List findEventList(IdWithCriteria idWithCriteria); diff --git a/src/main/java/com/hyundai/app/event/service/EventService.java b/src/main/java/com/hyundai/app/event/service/EventService.java index d591a49..b91619f 100644 --- a/src/main/java/com/hyundai/app/event/service/EventService.java +++ b/src/main/java/com/hyundai/app/event/service/EventService.java @@ -35,16 +35,15 @@ public class EventService { private final MemberCouponMapper memberCouponMapper; private final CouponMapper couponMapper; - public EventDetailResDto findCurrentEventByEventType(EventType eventType) { - EventDetailResDto eventDetailResDto = eventMapper.findCurrentEventByEventType(eventType); - if (eventDetailResDto == null) { - log.error("해당 타입의 이벤트가 존재하지 않습니다."); - throw new AdventureOfHeendyException(ErrorCode.EVENT_NOT_EXIST); + public List findCurrentEventByEventType(EventType eventType) { + List eventDetailResDtoList = eventMapper.findCurrentEventByEventType(eventType); + for (EventDetailResDto eventDetailResDto : eventDetailResDtoList) { + int eventId = eventDetailResDto.getId(); + List eventActiveTimeZoneDtoList = findEventActiveTime(eventId); + eventDetailResDto.setActiveTimeList(eventActiveTimeZoneDtoList); } - int eventId = eventDetailResDto.getId(); - List eventActiveTimeZoneDto = findEventActiveTime(eventId); - eventDetailResDto.setActiveTimeList(eventActiveTimeZoneDto); - return eventDetailResDto; + + return eventDetailResDtoList; } public EventListResDto findEventList(int storeId, int page, int size) { diff --git a/src/main/resources/mapper/CouponMapper.xml b/src/main/resources/mapper/CouponMapper.xml index 66cf889..5938e65 100644 --- a/src/main/resources/mapper/CouponMapper.xml +++ b/src/main/resources/mapper/CouponMapper.xml @@ -38,6 +38,7 @@ , minimum_amount , started_at , finished_at + , icon_url FROM coupon WHERE id IN (SELECT coupon_id FROM member_coupon diff --git a/src/main/resources/mapper/EventMapper.xml b/src/main/resources/mapper/EventMapper.xml index 15ff226..0639f50 100644 --- a/src/main/resources/mapper/EventMapper.xml +++ b/src/main/resources/mapper/EventMapper.xml @@ -14,6 +14,7 @@ , store_id , reward_type , reward + , icon_url FROM event WHERE sysdate BETWEEN started_at AND finished_at AND id IN (SELECT event_id @@ -22,7 +23,6 @@ AND (#{eventType} IS NULL OR event_type = #{eventType}) AND max_count >= visited_count AND is_deleted = 0 - FETCH FIRST 1 ROWS ONLY