Skip to content

Commit

Permalink
fix: 유저용 이벤트 조회 시 참여여부 포함하도록 수정
Browse files Browse the repository at this point in the history
- 유저용에서는 eventType 필터 포함하지 않도록 수정
  • Loading branch information
sangeun99 committed Mar 4, 2024
1 parent a5257b6 commit d1e0ea7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class EventController {

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

@PostMapping("{eventId}/participate")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class EventDetailResDto {
private int visitedCount;
private int couponId;
private String iconUrl;
private int isParticipated; // 0: 참여 안함, 1: 참여함 (유저용)
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 {
List<EventDetailResDto> findCurrentEventByEventType(EventType eventType);
List<EventDetailResDto> findCurrentEventByEventType(String memberId);

List<EventDetailResDto> findEventList(IdWithCriteria idWithCriteria);

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/hyundai/app/event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public class EventService {
private final MemberCouponMapper memberCouponMapper;
private final CouponMapper couponMapper;

public List<EventDetailResDto> findCurrentEventByEventType(EventType eventType) {
List<EventDetailResDto> eventDetailResDtoList = eventMapper.findCurrentEventByEventType(eventType);
public List<EventDetailResDto> findCurrentEventByEventType(String memberId) {

List<EventDetailResDto> eventDetailResDtoList = eventMapper.findCurrentEventByEventType(memberId);
for (EventDetailResDto eventDetailResDto : eventDetailResDtoList) {
int eventId = eventDetailResDto.getId();
List<EventActiveTimeZoneDto> eventActiveTimeZoneDtoList = findEventActiveTime(eventId);
Expand Down
10 changes: 8 additions & 2 deletions src/main/resources/mapper/EventMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- @author 엄상은 -->
<!-- @since 2024/02/18 -->
<!-- 이벤트 mapper -->
<select id="findCurrentEventByEventType" parameterType="eventtype" resultType="eventdetailresdto">
<select id="findCurrentEventByEventType" parameterType="String" resultType="eventdetailresdto">
SELECT id
, title
, content
Expand All @@ -15,12 +15,18 @@
, reward_type
, reward
, icon_url
, CASE WHEN EXISTS (SELECT 1
FROM member_event
WHERE event_id = event.id
AND member_id = #{memberId})
THEN 1
ELSE 0
END AS isParticipated
FROM event
WHERE sysdate BETWEEN started_at AND finished_at
AND id IN (SELECT event_id
FROM event_active_time
WHERE TO_NUMBER(TO_CHAR(sysdate, 'HH24')) BETWEEN openned_at AND closed_at)
AND (#{eventType} IS NULL OR event_type = #{eventType})
AND max_count >= visited_count
AND is_deleted = 0
</select>
Expand Down

0 comments on commit d1e0ea7

Please sign in to comment.