Skip to content

Commit

Permalink
Merge branch 'dev' into feat/cancel-meeting
Browse files Browse the repository at this point in the history
  • Loading branch information
Starlight258 authored Feb 14, 2024
2 parents b7a6d61 + cb7635d commit 1cdc7d2
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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;
Expand Down Expand Up @@ -83,4 +85,15 @@ public void cancelMeeting(Long meetingId) {
meeting.cancelMeeting();
}

@Transactional(readOnly = true)
public List<Member> 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());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,6 +14,8 @@
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;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -69,4 +73,18 @@ public ResponseEntity deleteMeeting(@PathVariable("meeting-id") Long meetingId)
return ResponseEntity.noContent().build();
}

@GetMapping("/{meeting-id}/users")
@Operation(summary = "회의 참가자 조회", description = "회의에 참가한 사용자를 조회한다.")
public ResponseEntity<ApiResult<MemberInfoListResponse>> getMeetingMembers(
@PathVariable("meeting-id") Long meetingId) {
List<MemberInfoResponse> memberInfoList = meetingService.getMeetingMembers(meetingId)
.stream()
.map(MemberInfoResponse::from)
.collect(Collectors.toList());

MemberInfoListResponse memberInfoListResponse = new MemberInfoListResponse(memberInfoList);

return ResponseEntity.ok(ApiUtils.success(memberInfoListResponse));
}

}
Original file line number Diff line number Diff line change
@@ -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<Meeting, Long> {

// Optional<Timer> findByUserId(Long id);
@Query("select m from Meeting m join fetch m.participants p join fetch p.member where m.id = :meetingId")
Optional<Meeting> findByIdWithParticipantsAndMembers(@Param("meetingId") Long meetingId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<MemberInfoResponse> members;


public MemberInfoListResponse(List<MemberInfoResponse> members) {
this.members = members;
}
}
13 changes: 4 additions & 9 deletions src/main/java/org/dnd/timeet/member/dto/MemberInfoResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
);
}
}

0 comments on commit 1cdc7d2

Please sign in to comment.