Skip to content

Commit

Permalink
fix: 유저용 쿠폰, 이벤트 조회 시 아이콘 포함
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeun99 committed Mar 2, 2024
1 parent 0620334 commit c38c49d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/hyundai/app/coupon/domain/Coupon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Random;

/**
Expand All @@ -30,8 +31,8 @@ public class EventController {
private static final Random random = new Random();

@GetMapping
@ApiOperation("유저용 현재 열린 이벤트 조회 API")
public AdventureOfHeendyResponse<EventDetailResDto> findCurrentEventByEventType(@RequestParam EventType eventType) {
@ApiOperation("유저용 현재 열린 이벤트 전체 조회 API")
public AdventureOfHeendyResponse<List<EventDetailResDto>> findCurrentEventByEventType(@RequestParam EventType eventType) {
return AdventureOfHeendyResponse.success("이벤트 목록을 가져왔습니다.", eventService.findCurrentEventByEventType(eventType));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/hyundai/app/event/domain/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ public class Event extends BaseEntity {
private String reward;
private int isDeleted;
private int storeId;
private String iconUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class EventDetailResDto {
private int maxCount;
private int visitedCount;
private int couponId;
private String iconUrl;
private List<EventActiveTimeZoneDto> eventActiveTimeZoneDto;

public void setActiveTimeList(List<EventActiveTimeZoneDto> eventActiveTimeZoneDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
@Mapper
public interface EventMapper {
EventDetailResDto findCurrentEventByEventType(EventType eventType);
List<EventDetailResDto> findCurrentEventByEventType(EventType eventType);

List<EventDetailResDto> findEventList(IdWithCriteria idWithCriteria);

Expand Down
17 changes: 8 additions & 9 deletions src/main/java/com/hyundai/app/event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<EventDetailResDto> findCurrentEventByEventType(EventType eventType) {
List<EventDetailResDto> eventDetailResDtoList = eventMapper.findCurrentEventByEventType(eventType);
for (EventDetailResDto eventDetailResDto : eventDetailResDtoList) {
int eventId = eventDetailResDto.getId();
List<EventActiveTimeZoneDto> eventActiveTimeZoneDtoList = findEventActiveTime(eventId);
eventDetailResDto.setActiveTimeList(eventActiveTimeZoneDtoList);
}
int eventId = eventDetailResDto.getId();
List<EventActiveTimeZoneDto> eventActiveTimeZoneDto = findEventActiveTime(eventId);
eventDetailResDto.setActiveTimeList(eventActiveTimeZoneDto);
return eventDetailResDto;

return eventDetailResDtoList;
}

public EventListResDto findEventList(int storeId, int page, int size) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/mapper/CouponMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
, minimum_amount
, started_at
, finished_at
, icon_url
FROM coupon
WHERE id IN (SELECT coupon_id
FROM member_coupon
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mapper/EventMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
</select>

<select id="findEventList" parameterType="idwithcriteria" resultType="eventdetailresdto">
Expand Down

0 comments on commit c38c49d

Please sign in to comment.