Skip to content

Commit

Permalink
feat : 이벤트에 참여한 회원 목록
Browse files Browse the repository at this point in the history
  • Loading branch information
Choi-Seong-Hyeok committed Feb 27, 2024
1 parent 93583e4 commit 94b8f0a
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import com.hyundai.app.event.dto.EventDetailResDto;
import com.hyundai.app.event.dto.EventListResDto;
import com.hyundai.app.event.dto.EventSaveReqDto;
import com.hyundai.app.event.dto.MemberEventDetailsResDto;
import com.hyundai.app.event.service.EventService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author 엄상은
* @since 2024/02/19
Expand Down Expand Up @@ -62,4 +65,19 @@ public AdventureOfHeendyResponse<Void> delete(@PathVariable final int eventId) {
int storeId = 1;
return AdventureOfHeendyResponse.success("이벤트를 삭제했습니다.", eventService.delete(storeId, eventId));
}

/**
* @author 최성혁
* @since 2024/02/27
* 이벤트 참여자 회원 목록 조회
*/

@GetMapping("/{eventId}/participants")
@ApiOperation("어드민용 이벤트 참여자 상세정보 조회 API")
public AdventureOfHeendyResponse<List<MemberEventDetailsResDto>> findEventParticipants(@PathVariable final int eventId) {
// TODO: 지점 ID 받아오는 부분 수정
int storeId = 1;
return AdventureOfHeendyResponse.success("이벤트의 참여자 상세 정보를 가져왔습니다.", eventService.findEventParticipants(eventId,storeId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.hyundai.app.event.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
* @author 최성혁
* @since 2024/02/27
* 이벤트에 참여한 회원 목록 응답 객체
*/
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class MemberEventDetailsResDto {

@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDateTime eventParticipationDate; // 이벤트 참여일
private String memberEmail;

@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate memberBirth;

@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDateTime memberJoinDate; // 멤버의 가입일
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.hyundai.app.event.mapper;

import com.hyundai.app.event.domain.MemberEvent;
import com.hyundai.app.event.dto.MemberEventDetailsResDto;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* @author 엄상은
* @since 2024/02/21
Expand All @@ -11,4 +14,5 @@
@Mapper
public interface MemberEventMapper {
void saveMemberEvent(MemberEvent memberEvent);
List<MemberEventDetailsResDto> getMemberEventDetails(int eventId);
}
14 changes: 14 additions & 0 deletions src/main/java/com/hyundai/app/event/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,18 @@ public EventDetailResDto getRandomSpotDetail(String eventType) {
log.debug("랜덤 스팟 상세 정보 조회 : " + eventDetailResDto);
return eventDetailResDto;
}

/**
* @author 최성혁
* @since 2024/02/27
* 특정 이벤트에 참여중인 회원 목록
*/

public List<MemberEventDetailsResDto> findEventParticipants(int eventId, int id) {
List<MemberEventDetailsResDto> participants = memberEventMapper.getMemberEventDetails(eventId);

log.debug("Event ID " + eventId + "에 대한 참여자 상세 정보: " + participants);

return memberEventMapper.getMemberEventDetails(eventId);
}
}
18 changes: 18 additions & 0 deletions src/main/resources/mapper/MemberEventMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,22 @@
VALUES (#{memberId}
, #{eventId})
</insert>

<!-- @author 최성혁 -->
<!-- @since 2024/02/27 -->
<!-- 이벤트에 참여한 멤버 mapper -->
<select id="getMemberEventDetails">
SELECT
me.created_at AS eventParticipationDate,
m.email AS memberEmail,
m.birth AS memberBirth,
m.created_at AS memberJoinDate
FROM
member_event me
JOIN
member m ON me.member_id = m.id
WHERE
me.event_id = #{eventId}
</select>

</mapper>

0 comments on commit 94b8f0a

Please sign in to comment.