From c8b0e081f3b5d8f691b5bf4daa39dcc790af123c Mon Sep 17 00:00:00 2001 From: FacerAin Date: Mon, 12 Feb 2024 19:48:45 +0900 Subject: [PATCH 1/3] [#-] chore: fix typo in MeetingInfoResponse --- .../java/org/dnd/timeet/meeting/dto/MeetingInfoResponse.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/dnd/timeet/meeting/dto/MeetingInfoResponse.java b/src/main/java/org/dnd/timeet/meeting/dto/MeetingInfoResponse.java index 11b2730..39e9080 100644 --- a/src/main/java/org/dnd/timeet/meeting/dto/MeetingInfoResponse.java +++ b/src/main/java/org/dnd/timeet/meeting/dto/MeetingInfoResponse.java @@ -5,8 +5,6 @@ import lombok.Getter; import lombok.Setter; import org.dnd.timeet.meeting.domain.Meeting; -import org.dnd.timeet.timer.domain.Timer; -import org.dnd.timeet.timer.domain.TimerStatus; @Schema(description = "회의 정보 응답") @Getter @@ -19,7 +17,7 @@ public class MeetingInfoResponse { @Schema(description = "회의 제목", example = "2차 회의") private String title; - @Schema(description = "회의 목", example = "2개의 사안 모두 해결하기") + @Schema(description = "회의 목표", example = "2개의 사안 모두 해결하기") private String description; @Builder From e4b31b8e537b55d7aa5132307d520ab29969351f Mon Sep 17 00:00:00 2001 From: FacerAin Date: Mon, 12 Feb 2024 19:51:25 +0900 Subject: [PATCH 2/3] [#28] feat: Add getMeetingMembers --- .../meeting/application/MeetingService.java | 20 ++++++++++++++----- .../meeting/controller/MeetingController.java | 15 ++++++++++++++ .../meeting/domain/MeetingRepository.java | 7 ++++++- .../timeet/member/dto/MemberInfoResponse.java | 13 ++++-------- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/dnd/timeet/meeting/application/MeetingService.java b/src/main/java/org/dnd/timeet/meeting/application/MeetingService.java index ca76540..acec501 100644 --- a/src/main/java/org/dnd/timeet/meeting/application/MeetingService.java +++ b/src/main/java/org/dnd/timeet/meeting/application/MeetingService.java @@ -1,18 +1,17 @@ package org.dnd.timeet.meeting.application; import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.dnd.timeet.common.exception.BadRequestError; import org.dnd.timeet.common.exception.NotFoundError; - import org.dnd.timeet.meeting.domain.Meeting; import org.dnd.timeet.meeting.domain.MeetingRepository; - -import org.dnd.timeet.participant.domain.Participant; -import org.dnd.timeet.participant.domain.ParticipantRepository; import org.dnd.timeet.meeting.dto.MeetingCreateRequest; import org.dnd.timeet.member.domain.Member; -import org.springframework.data.crossstore.ChangeSetPersister.NotFoundException; +import org.dnd.timeet.participant.domain.Participant; +import org.dnd.timeet.participant.domain.ParticipantRepository; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -78,4 +77,15 @@ public void removeParticipant(Long meetingId, Member member) { } + @Transactional(readOnly = true) + public List getMeetingMembers(Long meetingId) { + Meeting meeting = meetingRepository.findByIdWithParticipantsAndMembers(meetingId) + .orElseThrow(() -> new NotFoundError(NotFoundError.ErrorCode.RESOURCE_NOT_FOUND, + Collections.singletonMap("MeetingId", "Meeting not found"))); + + return meeting.getParticipants().stream() + .map(Participant::getMember) + .collect(Collectors.toList()); + } + } diff --git a/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java b/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java index 32ecb2a..c252980 100644 --- a/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java +++ b/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java @@ -3,6 +3,8 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.util.List; +import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.dnd.timeet.common.security.CustomUserDetails; import org.dnd.timeet.common.utils.ApiUtils; @@ -12,6 +14,7 @@ import org.dnd.timeet.meeting.dto.MeetingCreateRequest; import org.dnd.timeet.meeting.dto.MeetingCreateResponse; import org.dnd.timeet.meeting.dto.MeetingInfoResponse; +import org.dnd.timeet.member.dto.MemberInfoResponse; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; @@ -61,4 +64,16 @@ public ResponseEntity> getTimerById(@PathVariable return ResponseEntity.ok(ApiUtils.success(meetingInfoResponse)); } + @GetMapping("/{meeting-id}/users") + @Operation(summary = "회의 참가자 조회", description = "회의에 참가한 사용자를 조회한다.") + public ResponseEntity getMeetingMembers(@PathVariable("meeting-id") Long meetingId) { + List memberInfoReponseList = meetingService.getMeetingMembers(meetingId) + .stream() + .map(MemberInfoResponse::from) + .collect(Collectors.toList()); + + return ResponseEntity.ok(ApiUtils.success(memberInfoReponseList)); + } + + } diff --git a/src/main/java/org/dnd/timeet/meeting/domain/MeetingRepository.java b/src/main/java/org/dnd/timeet/meeting/domain/MeetingRepository.java index f0f9304..920e1b6 100644 --- a/src/main/java/org/dnd/timeet/meeting/domain/MeetingRepository.java +++ b/src/main/java/org/dnd/timeet/meeting/domain/MeetingRepository.java @@ -1,8 +1,13 @@ package org.dnd.timeet.meeting.domain; +import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; public interface MeetingRepository extends JpaRepository { -// Optional findByUserId(Long id); + @Query("select m from Meeting m join fetch m.participants p join fetch p.member where m.id = :meetingId") + Optional findByIdWithParticipantsAndMembers(@Param("meetingId") Long meetingId); + } diff --git a/src/main/java/org/dnd/timeet/member/dto/MemberInfoResponse.java b/src/main/java/org/dnd/timeet/member/dto/MemberInfoResponse.java index ef336c4..84a503e 100644 --- a/src/main/java/org/dnd/timeet/member/dto/MemberInfoResponse.java +++ b/src/main/java/org/dnd/timeet/member/dto/MemberInfoResponse.java @@ -4,7 +4,6 @@ import lombok.Getter; import lombok.Setter; import org.dnd.timeet.member.domain.Member; -import org.dnd.timeet.member.domain.MemberRole; @Getter @Setter @@ -13,22 +12,18 @@ public class MemberInfoResponse { @Schema(description = "사용자 id", nullable = false, example = "12") private long id; @Schema(description = "사용자 이름", nullable = false, example = "green12") - private String username; - @Schema(description = "사용자 역할", nullable = false, example = "ROLE_USER") - private MemberRole role; + private String name; - public MemberInfoResponse(long id, String username, MemberRole role) { + public MemberInfoResponse(long id, String name) { this.id = id; - this.username = username; - this.role = role; + this.name = name; } public static MemberInfoResponse from(Member member) { return new MemberInfoResponse( member.getId(), - member.getName(), - member.getRole() + member.getName() ); } } From e4d823d6ff20e7f07eb343fac05b6d4b4c0f2009 Mon Sep 17 00:00:00 2001 From: FacerAin Date: Wed, 14 Feb 2024 14:27:37 +0900 Subject: [PATCH 3/3] [#28] feat: Add MemberInfoListResponse --- .../meeting/controller/MeetingController.java | 10 +++++++--- .../member/dto/MemberInfoListResponse.java | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/dnd/timeet/member/dto/MemberInfoListResponse.java diff --git a/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java b/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java index c252980..cfdd6ef 100644 --- a/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java +++ b/src/main/java/org/dnd/timeet/meeting/controller/MeetingController.java @@ -14,6 +14,7 @@ import org.dnd.timeet.meeting.dto.MeetingCreateRequest; import org.dnd.timeet.meeting.dto.MeetingCreateResponse; import org.dnd.timeet.meeting.dto.MeetingInfoResponse; +import org.dnd.timeet.member.dto.MemberInfoListResponse; import org.dnd.timeet.member.dto.MemberInfoResponse; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -66,13 +67,16 @@ public ResponseEntity> getTimerById(@PathVariable @GetMapping("/{meeting-id}/users") @Operation(summary = "회의 참가자 조회", description = "회의에 참가한 사용자를 조회한다.") - public ResponseEntity getMeetingMembers(@PathVariable("meeting-id") Long meetingId) { - List memberInfoReponseList = meetingService.getMeetingMembers(meetingId) + public ResponseEntity> getMeetingMembers( + @PathVariable("meeting-id") Long meetingId) { + List memberInfoList = meetingService.getMeetingMembers(meetingId) .stream() .map(MemberInfoResponse::from) .collect(Collectors.toList()); - return ResponseEntity.ok(ApiUtils.success(memberInfoReponseList)); + MemberInfoListResponse memberInfoListResponse = new MemberInfoListResponse(memberInfoList); + + return ResponseEntity.ok(ApiUtils.success(memberInfoListResponse)); } diff --git a/src/main/java/org/dnd/timeet/member/dto/MemberInfoListResponse.java b/src/main/java/org/dnd/timeet/member/dto/MemberInfoListResponse.java new file mode 100644 index 0000000..83ce930 --- /dev/null +++ b/src/main/java/org/dnd/timeet/member/dto/MemberInfoListResponse.java @@ -0,0 +1,18 @@ +package org.dnd.timeet.member.dto; + +import java.util.List; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class MemberInfoListResponse { + + + private List members; + + + public MemberInfoListResponse(List members) { + this.members = members; + } +}