diff --git a/src/docs/asciidoc/member-information.adoc b/src/docs/asciidoc/member-information.adoc index feacaa4b..eaca8309 100644 --- a/src/docs/asciidoc/member-information.adoc +++ b/src/docs/asciidoc/member-information.adoc @@ -5,7 +5,7 @@ :toc: left :toclevels: 2 -== 사용자 기본 정보 [AccessToken 필수] +== 사용자 기본 정보 HTTP Request include::{snippets}/MemberApi/Information/Basic/http-request.adoc[] include::{snippets}/MemberApi/Information/Basic/request-headers.adoc[] @@ -36,27 +36,6 @@ HTTP Response include::{snippets}/MemberApi/Information/RelatedStudy/Apply/Success/response-body.adoc[] include::{snippets}/MemberApi/Information/RelatedStudy/Apply/Success/response-fields.adoc[] -== 사용자가 참여중인 스터디 리스트 [AccessToken 필수] -=== 1. Private한 사용자 정보는 타인이 조회할 수 없다 (Token PayloadId != PathVariable memberId) -HTTP Request -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Failure/http-request.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Failure/request-headers.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Failure/path-parameters.adoc[] - -HTTP Response -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Failure/response-body.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Failure/response-fields.adoc[] - -=== 2. 사용자가 참여중인 스터디 리스트를 조회한다 -HTTP Request -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Success/http-request.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Success/request-headers.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Success/path-parameters.adoc[] - -HTTP Response -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Success/response-body.adoc[] -include::{snippets}/MemberApi/Information/RelatedStudy/Participate/Success/response-fields.adoc[] - == 사용자가 찜한 스터디 리스트 [AccessToken 필수] === 1. Private한 사용자 정보는 타인이 조회할 수 없다 (Token PayloadId != PathVariable memberId) HTTP Request @@ -78,7 +57,17 @@ HTTP Response include::{snippets}/MemberApi/Information/RelatedStudy/Favorite/Success/response-body.adoc[] include::{snippets}/MemberApi/Information/RelatedStudy/Favorite/Success/response-fields.adoc[] -== 사용자가 졸업한 스터디 리스트 [AccessToken 필수] +== 사용자가 참여중인 스터디 리스트 +HTTP Request +include::{snippets}/MemberApi/Information/RelatedStudy/Participate/http-request.adoc[] +include::{snippets}/MemberApi/Information/RelatedStudy/Participate/request-headers.adoc[] +include::{snippets}/MemberApi/Information/RelatedStudy/Participate/path-parameters.adoc[] + +HTTP Response +include::{snippets}/MemberApi/Information/RelatedStudy/Participate/response-body.adoc[] +include::{snippets}/MemberApi/Information/RelatedStudy/Participate/response-fields.adoc[] + +== 사용자가 졸업한 스터디 리스트 HTTP Request include::{snippets}/MemberApi/Information/RelatedStudy/Graduated/http-request.adoc[] include::{snippets}/MemberApi/Information/RelatedStudy/Graduated/request-headers.adoc[] @@ -88,7 +77,7 @@ HTTP Response include::{snippets}/MemberApi/Information/RelatedStudy/Graduated/response-body.adoc[] include::{snippets}/MemberApi/Information/RelatedStudy/Graduated/response-fields.adoc[] -== 사용자의 피어리뷰 조회 [AccessToken 필수] +== 사용자의 피어리뷰 조회 HTTP Request include::{snippets}/MemberApi/Information/PeerReview/http-request.adoc[] include::{snippets}/MemberApi/Information/PeerReview/request-headers.adoc[] @@ -98,7 +87,7 @@ HTTP Response include::{snippets}/MemberApi/Information/PeerReview/response-body.adoc[] include::{snippets}/MemberApi/Information/PeerReview/response-fields.adoc[] -== 사용자 출석률 조회 [AccessToken 필수] +== 사용자 출석률 조회 HTTP Request include::{snippets}/MemberApi/Information/Attendances/http-request.adoc[] include::{snippets}/MemberApi/Information/Attendances/request-headers.adoc[] diff --git a/src/docs/asciidoc/member-signup.adoc b/src/docs/asciidoc/member-signup.adoc index 6f91b642..1782565d 100644 --- a/src/docs/asciidoc/member-signup.adoc +++ b/src/docs/asciidoc/member-signup.adoc @@ -23,7 +23,7 @@ include::{snippets}/MemberApi/SignUp/Success/request-fields.adoc[] HTTP Response include::{snippets}/MemberApi/SignUp/Success/http-response.adoc[] -== 정보 수정 [AccessToken 필수] +== 사용자 정보 수정 [AccessToken 필수] HTTP Request include::{snippets}/MemberApi/Update/http-request.adoc[] include::{snippets}/MemberApi/Update/request-headers.adoc[] diff --git a/src/docs/asciidoc/oauth.adoc b/src/docs/asciidoc/oauth.adoc index 390a3b2f..4d63812a 100644 --- a/src/docs/asciidoc/oauth.adoc +++ b/src/docs/asciidoc/oauth.adoc @@ -33,7 +33,7 @@ HTTP Response include::{snippets}/OAuthApi/Login/Success/response-body.adoc[] include::{snippets}/OAuthApi/Login/Success/response-fields.adoc[] -== 로그아웃 [AccessToken 필수] +== 사용자 로그아웃 [AccessToken 필수] HTTP Request include::{snippets}/OAuthApi/Logout/http-request.adoc[] include::{snippets}/OAuthApi/Logout/request-headers.adoc[] diff --git a/src/docs/asciidoc/study-information.adoc b/src/docs/asciidoc/study-information.adoc index 72e06f25..d113916b 100644 --- a/src/docs/asciidoc/study-information.adoc +++ b/src/docs/asciidoc/study-information.adoc @@ -71,8 +71,8 @@ HTTP Response include::{snippets}/StudyApi/Information/Participants/response-body.adoc[] include::{snippets}/StudyApi/Information/Participants/response-fields.adoc[] -== 스터디 주차별 출석 정보 조회 [AccessToken 필수] -=== 1. 스터디 참여자가 아니라면 스터디 주차별 출석 정보를 조회할 수 없다 +== 스터디 사용자별 출석 정보 조회 [AccessToken 필수] +=== 1. 스터디 참여자가 아니라면 스터디 사용자별 출석 정보를 조회할 수 없다 HTTP Request include::{snippets}/StudyApi/Information/Attendances/Failure/http-request.adoc[] include::{snippets}/StudyApi/Information/Attendances/Failure/request-headers.adoc[] @@ -81,7 +81,7 @@ include::{snippets}/StudyApi/Information/Attendances/Failure/path-parameters.ado HTTP Response include::{snippets}/StudyApi/Information/Attendances/Failure/response-body.adoc[] -=== 2. 스터디 주차별 출석 정보를 조회한다 +=== 2. 스터디 사용자별 출석 정보를 조회한다 HTTP Request include::{snippets}/StudyApi/Information/Attendances/Success/http-request.adoc[] include::{snippets}/StudyApi/Information/Attendances/Success/path-parameters.adoc[] diff --git a/src/docs/asciidoc/study-review.adoc b/src/docs/asciidoc/study-review.adoc index 8395e351..9f13d660 100644 --- a/src/docs/asciidoc/study-review.adoc +++ b/src/docs/asciidoc/study-review.adoc @@ -45,7 +45,7 @@ include::{snippets}/StudyApi/Review/Remove/Success/path-parameters.adoc[] HTTP Response include::{snippets}/StudyApi/Review/Remove/Success/http-response.adoc[] -== 리뷰 수정 [AccessToken 필수] +== 스터디 리뷰 수정 [AccessToken 필수] === 1. 작성자가 아니면 리뷰를 수정할 수 없다 HTTP Request include::{snippets}/StudyApi/Review/Update/Failure/http-request.adoc[] diff --git a/src/main/java/com/kgu/studywithme/member/controller/MemberInformationApiController.java b/src/main/java/com/kgu/studywithme/member/controller/MemberInformationApiController.java index 8d1f637e..977fcf65 100644 --- a/src/main/java/com/kgu/studywithme/member/controller/MemberInformationApiController.java +++ b/src/main/java/com/kgu/studywithme/member/controller/MemberInformationApiController.java @@ -18,7 +18,7 @@ public class MemberInformationApiController { private final MemberInformationService memberInformationService; @GetMapping - public ResponseEntity getInformation(@ExtractPayload Long payloadId, @PathVariable Long memberId) { + public ResponseEntity getInformation(@PathVariable Long memberId) { MemberInformation response = memberInformationService.getInformation(memberId); return ResponseEntity.ok(response); } @@ -30,13 +30,6 @@ public ResponseEntity getApplyStudy(@ExtractPayload Long payloadId return ResponseEntity.ok(response); } - @CheckMemberIdentity - @GetMapping("/studies/participate") - public ResponseEntity getParticipateStudy(@ExtractPayload Long payloadId, @PathVariable Long memberId) { - RelatedStudy response = memberInformationService.getParticipateStudy(memberId); - return ResponseEntity.ok(response); - } - @CheckMemberIdentity @GetMapping("/studies/favorite") public ResponseEntity getFavoriteStudy(@ExtractPayload Long payloadId, @PathVariable Long memberId) { @@ -44,20 +37,26 @@ public ResponseEntity getFavoriteStudy(@ExtractPayload Long payloa return ResponseEntity.ok(response); } + @GetMapping("/studies/participate") + public ResponseEntity getParticipateStudy(@PathVariable Long memberId) { + RelatedStudy response = memberInformationService.getParticipateStudy(memberId); + return ResponseEntity.ok(response); + } + @GetMapping("/studies/graduated") - public ResponseEntity getGraduatedStudy(@ExtractPayload Long payloadId, @PathVariable Long memberId) { + public ResponseEntity getGraduatedStudy(@PathVariable Long memberId) { GraduatedStudy response = memberInformationService.getGraduatedStudy(memberId); return ResponseEntity.ok(response); } @GetMapping("/reviews") - public ResponseEntity getReviews(@ExtractPayload Long payloadId, @PathVariable Long memberId) { + public ResponseEntity getReviews(@PathVariable Long memberId) { PeerReviewAssembler response = memberInformationService.getPeerReviews(memberId); return ResponseEntity.ok(response); } @GetMapping("/attendances") - public ResponseEntity getAttendanceRatio(@ExtractPayload Long payloadId, @PathVariable Long memberId) { + public ResponseEntity getAttendanceRatio(@PathVariable Long memberId) { AttendanceRatioAssembler response = memberInformationService.getAttendanceRatio(memberId); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryImpl.java b/src/main/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryImpl.java index 421a50de..6c7c6a73 100644 --- a/src/main/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryImpl.java +++ b/src/main/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryImpl.java @@ -79,13 +79,9 @@ private List includeMissingAttendanceStatus(List ratio.status() == status) .findFirst() - .orElse(null); + .orElse(new AttendanceRatio(status, 0)); - result.add( - specificAttendanceRatio != null - ? specificAttendanceRatio - : new AttendanceRatio(status, 0) - ); + result.add(specificAttendanceRatio); } return result; diff --git a/src/main/java/com/kgu/studywithme/study/domain/StudyThumbnail.java b/src/main/java/com/kgu/studywithme/study/domain/StudyThumbnail.java index 93eb13cc..bafd4652 100644 --- a/src/main/java/com/kgu/studywithme/study/domain/StudyThumbnail.java +++ b/src/main/java/com/kgu/studywithme/study/domain/StudyThumbnail.java @@ -17,8 +17,6 @@ public enum StudyThumbnail { IMAGE_LANGUAGE_005("language_TEPS.png", "#FFFBE8"), IMAGE_LANGUAGE_006("language_TOEFL.png", "#FFFFFF"), IMAGE_LANGUAGE_007("language_TOEIC.png", "#FFFFFF"), - IMAGE_LANGUAGE_008("language_001.png", "#E7E7E7"), - IMAGE_LANGUAGE_009("language_toeic.png", "#E7E7E7"), IMAGE_INTERVIEW_001("interview_samsung.png", "#E3EDFF"), IMAGE_INTERVIEW_002("interview_hyundai.png", "#EFF1FF"), @@ -33,7 +31,6 @@ public enum StudyThumbnail { IMAGE_PROGRAMMING_005("programming_Baekjoon.png", "#FFFFFF"), IMAGE_PROGRAMMING_006("programming_CSS.png", "#E5F9FF"), IMAGE_PROGRAMMING_007("programming_HTML.png", "#FFEEDB"), - IMAGE_PROGRAMMING_008("programming_baekjoon.png", "#E7E7E7"), IMAGE_APTITUDE_NCS_001("aptitude_ncs_001.png", "#FF0000"), IMAGE_APTITUDE_NCS_002("aptitude_ncs_002.png", "#FF0000"), @@ -46,7 +43,6 @@ public enum StudyThumbnail { IMAGE_CERTIFICATION_003("certification_CSSD.png", "#E7E7E7"), IMAGE_CERTIFICATION_004("certification_KH.png", "#E7E7E7"), IMAGE_CERTIFICATION_005("certification_GTQ.png", "#E7E7E7"), - IMAGE_CERTIFICATION_006("certification_computerLiteracy.png", "#E7E7E7"), IMAGE_ETC_001("etc_teacherExam.png", "#FFFFFF"), IMAGE_ETC_002("etc_002.png", "#FF0000"), diff --git a/src/main/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryImpl.java b/src/main/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryImpl.java index a7fd7b3a..9328b029 100644 --- a/src/main/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryImpl.java +++ b/src/main/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryImpl.java @@ -8,14 +8,16 @@ import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; +import java.util.Collection; import java.util.List; +import java.util.stream.Stream; import static com.kgu.studywithme.member.domain.QMember.member; +import static com.kgu.studywithme.study.domain.QStudy.study; import static com.kgu.studywithme.study.domain.attendance.QAttendance.attendance; import static com.kgu.studywithme.study.domain.notice.QNotice.notice; import static com.kgu.studywithme.study.domain.notice.comment.QComment.comment; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.APPLY; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.GRADUATED; +import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.*; import static com.kgu.studywithme.study.domain.participant.QParticipant.participant; import static com.kgu.studywithme.study.domain.review.QReview.review; import static com.kgu.studywithme.study.domain.week.submit.QSubmit.submit; @@ -38,7 +40,7 @@ public int getGraduatedParticipantCountByStudyId(Long studyId) { @Override public List findReviewByStudyId(Long studyId) { return query - .select(new QReviewInformation(member.id, member.nickname, review.content, review.modifiedAt)) + .select(new QReviewInformation(review.id, review.content, review.modifiedAt, member.id, member.nickname)) .from(review) .innerJoin(review.writer, member) .where(review.study.id.eq(studyId)) @@ -51,7 +53,8 @@ public List findNoticeWithCommentsByStudyId(Long studyId) { List noticeResult = query .select(new QNoticeInformation( notice.id, notice.title, notice.content, notice.createdAt, notice.modifiedAt, - member.id, member.nickname)) + member.id, member.nickname + )) .from(notice) .innerJoin(notice.writer, member) .where(notice.study.id.eq(studyId)) @@ -64,9 +67,13 @@ public List findNoticeWithCommentsByStudyId(Long studyId) { private void applyCommentsInNotice(List noticeResult) { List commentResult = query - .select(new QCommentInformation(comment.id, comment.notice.id, comment.content, member.id, member.nickname)) + .select(new QCommentInformation( + comment.id, comment.notice.id, comment.content, comment.modifiedAt, + member.id, member.nickname + )) .from(comment) .innerJoin(comment.writer, member) + .orderBy(comment.id.asc()) .fetch(); noticeResult.forEach(notice -> notice.applyComments( @@ -83,19 +90,40 @@ public List findApplicantByStudyId(Long studyId) { .from(participant) .innerJoin(participant.member, member) .where(studyIdEq(studyId), applyStatus()) - .orderBy(participant.id.desc()) + .orderBy(member.id.desc()) .fetch(); } @Override public List findAttendanceByStudyId(Long studyId) { + Long hostId = query + .select(study.participants.host.id) + .from(study) + .where(study.id.eq(studyId)) + .fetchOne(); + + List participantIds = query + .select(participant.member.id) + .from(participant) + .where( + participant.study.id.eq(studyId), + participant.status.eq(APPROVE) + ) + .fetch(); + + List totalIds = Stream.of(List.of(hostId), participantIds) + .flatMap(Collection::stream) + .toList(); + return query - .select(new QAttendanceInformation(member.id, member.nickname, participant.status, attendance.week, attendance.status)) + .select(new QAttendanceInformation(member.id, member.nickname, attendance.week, attendance.status)) .from(attendance) .innerJoin(attendance.participant, member) - .leftJoin(participant).on(participant.member.id.eq(member.id)) - .where(attendance.study.id.eq(studyId)) - .orderBy(attendance.week.asc(), member.id.asc()) + .where( + attendance.study.id.eq(studyId), + member.id.in(totalIds) + ) + .orderBy(member.id.asc(), attendance.week.asc()) .fetch(); } diff --git a/src/main/java/com/kgu/studywithme/study/infra/query/StudySimpleQueryRepositoryImpl.java b/src/main/java/com/kgu/studywithme/study/infra/query/StudySimpleQueryRepositoryImpl.java index 0c984b4f..6e3feae1 100644 --- a/src/main/java/com/kgu/studywithme/study/infra/query/StudySimpleQueryRepositoryImpl.java +++ b/src/main/java/com/kgu/studywithme/study/infra/query/StudySimpleQueryRepositoryImpl.java @@ -37,7 +37,11 @@ public List findApplyStudyByMemberId(Long memberId) { .selectDistinct(new QSimpleStudy(study.id, study.name, study.category, study.thumbnail)) .from(study) .innerJoin(participant).on(participant.study.id.eq(study.id)) - .where(memberIdEq(memberId), participateStatusEq(APPLY)) + .where( + memberIdEq(memberId), + participateStatusEq(APPLY), + studyIsNotClosed() + ) .orderBy(study.id.desc()) .fetch(); } @@ -49,7 +53,10 @@ public List findParticipateStudyByMemberId(Long memberId) { .from(study) .innerJoin(study.participants.host, host) .leftJoin(participant).on(participant.study.id.eq(study.id)) - .where(hostIdEq(memberId).or(participantIdEqAndApproveStatus(memberId))) + .where( + hostIdEq(memberId).or(participantIdEqAndApproveStatus(memberId)), + studyIsNotClosed() + ) .orderBy(study.id.desc()) .fetch(); } @@ -213,4 +220,8 @@ private BooleanExpression hostIdEq(Long memberId) { private BooleanExpression isMemberInParticipant(Long memberId, List participantIds) { return !CollectionUtils.isEmpty(participantIds) ? Expressions.asNumber(memberId).in(participantIds) : null; } + + private BooleanExpression studyIsNotClosed() { + return study.closed.eq(false); + } } diff --git a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/AttendanceInformation.java b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/AttendanceInformation.java index be13a6ac..5bbddf7c 100644 --- a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/AttendanceInformation.java +++ b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/AttendanceInformation.java @@ -2,31 +2,21 @@ import com.kgu.studywithme.member.domain.Nickname; import com.kgu.studywithme.study.domain.attendance.AttendanceStatus; -import com.kgu.studywithme.study.domain.participant.ParticipantStatus; -import com.kgu.studywithme.study.service.dto.response.StudyAttendanceMember; +import com.kgu.studywithme.study.service.dto.response.StudyMember; import com.querydsl.core.annotations.QueryProjection; import lombok.AllArgsConstructor; import lombok.Getter; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.APPROVE; - @Getter @AllArgsConstructor public class AttendanceInformation { - private final StudyAttendanceMember participant; + private final StudyMember participant; private final int week; private final String attendanceStatus; @QueryProjection - public AttendanceInformation( - Long id, Nickname nickname, ParticipantStatus participantStatus, - int week, AttendanceStatus attendanceStatus - ) { - this.participant = new StudyAttendanceMember( - id, - nickname.getValue(), - (participantStatus == null) ? APPROVE : participantStatus - ); + public AttendanceInformation(Long id, Nickname nickname, int week, AttendanceStatus attendanceStatus) { + this.participant = new StudyMember(id, nickname.getValue()); this.week = week; this.attendanceStatus = attendanceStatus.getDescription(); } diff --git a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/CommentInformation.java b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/CommentInformation.java index 6fff0a52..396c132d 100644 --- a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/CommentInformation.java +++ b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/CommentInformation.java @@ -6,19 +6,23 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import java.time.LocalDateTime; + @Getter @AllArgsConstructor public class CommentInformation { private final Long id; private final Long noticeId; private final String content; + private final LocalDateTime writeDate; private final StudyMember writer; @QueryProjection - public CommentInformation(Long id, Long noticeId, String content, Long writerId, Nickname writerNickname) { + public CommentInformation(Long id, Long noticeId, String content, LocalDateTime writeDate, Long writerId, Nickname writerNickname) { this.id = id; this.noticeId = noticeId; this.content = content; + this.writeDate = writeDate; this.writer = new StudyMember(writerId, writerNickname.getValue()); } } diff --git a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/ReviewInformation.java b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/ReviewInformation.java index 65b84939..9aed268d 100644 --- a/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/ReviewInformation.java +++ b/src/main/java/com/kgu/studywithme/study/infra/query/dto/response/ReviewInformation.java @@ -11,14 +11,16 @@ @Getter @AllArgsConstructor public class ReviewInformation { - private final StudyMember reviewer; + private final Long id; private final String content; private final LocalDateTime reviewDate; + private final StudyMember reviewer; @QueryProjection - public ReviewInformation(Long reviewerId, Nickname reviewerNickname, String content, LocalDateTime reviewDate) { - this.reviewer = new StudyMember(reviewerId, reviewerNickname.getValue()); + public ReviewInformation(Long id, String content, LocalDateTime reviewDate, Long reviewerId, Nickname reviewerNickname) { + this.id = id; this.content = content; this.reviewDate = reviewDate; + this.reviewer = new StudyMember(reviewerId, reviewerNickname.getValue()); } } diff --git a/src/main/java/com/kgu/studywithme/study/service/StudyInformationService.java b/src/main/java/com/kgu/studywithme/study/service/StudyInformationService.java index 8ad4e4c3..4c4e46cd 100644 --- a/src/main/java/com/kgu/studywithme/study/service/StudyInformationService.java +++ b/src/main/java/com/kgu/studywithme/study/service/StudyInformationService.java @@ -52,6 +52,7 @@ public StudyParticipant getApproveParticipants(Long studyId) { .stream() .map(StudyMember::new) .toList(); + return new StudyParticipant(host, participants); } diff --git a/src/main/java/com/kgu/studywithme/study/service/dto/response/StudyMemberAttendanceResult.java b/src/main/java/com/kgu/studywithme/study/service/dto/response/StudyMemberAttendanceResult.java index e682604a..b5eec2e8 100644 --- a/src/main/java/com/kgu/studywithme/study/service/dto/response/StudyMemberAttendanceResult.java +++ b/src/main/java/com/kgu/studywithme/study/service/dto/response/StudyMemberAttendanceResult.java @@ -3,7 +3,7 @@ import java.util.List; public record StudyMemberAttendanceResult( - StudyAttendanceMember member, + StudyMember member, List summaries ) { } diff --git a/src/test/java/com/kgu/studywithme/member/controller/MemberApiControllerTest.java b/src/test/java/com/kgu/studywithme/member/controller/MemberApiControllerTest.java index 217a9cdf..f714c0e0 100644 --- a/src/test/java/com/kgu/studywithme/member/controller/MemberApiControllerTest.java +++ b/src/test/java/com/kgu/studywithme/member/controller/MemberApiControllerTest.java @@ -139,14 +139,14 @@ void success() throws Exception { } @Nested - @DisplayName("사용자 정보 수정 [PATCH /api/members/{memberId}]") + @DisplayName("사용자 정보 수정 [PATCH /api/members/{memberId}] - AccessToken 필수") class update { private static final String BASE_URL = "/api/members/{memberId}"; private static final Long MEMBER_ID = 1L; @Test @DisplayName("사용자 정보를 수정한다") - void update() throws Exception { + void success() throws Exception { // given given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); given(jwtTokenProvider.getId(anyString())).willReturn(MEMBER_ID); diff --git a/src/test/java/com/kgu/studywithme/member/controller/MemberInformationApiControllerTest.java b/src/test/java/com/kgu/studywithme/member/controller/MemberInformationApiControllerTest.java index 0cbd7401..9dce72b7 100644 --- a/src/test/java/com/kgu/studywithme/member/controller/MemberInformationApiControllerTest.java +++ b/src/test/java/com/kgu/studywithme/member/controller/MemberInformationApiControllerTest.java @@ -40,7 +40,7 @@ @DisplayName("Member [Controller Layer] -> MemberInformationApiController 테스트") class MemberInformationApiControllerTest extends ControllerTest { @Nested - @DisplayName("사용자 기본 정보 조회 API [GET /api/members/{memberId}] - AccessToken 필수") + @DisplayName("사용자 기본 정보 조회 API [GET /api/members/{memberId}]") class getInformation { private static final String BASE_URL = "/api/members/{memberId}"; private static final Long MEMBER_ID = 1L; @@ -175,9 +175,9 @@ void success() throws Exception { } @Nested - @DisplayName("사용자가 참여중인 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/participate] - AccessToken 필수") - class getParticipateStudy { - private static final String BASE_URL = "/api/members/{memberId}/studies/participate"; + @DisplayName("사용자가 찜한 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/favorite] - AccessToken 필수") + class getFavoriteStudy { + private static final String BASE_URL = "/api/members/{memberId}/studies/favorite"; private static final Long MEMBER_ID = 1L; @Test @@ -206,7 +206,7 @@ void throwExceptionByInvalidPermission() throws Exception { ) .andDo( document( - "MemberApi/Information/RelatedStudy/Participate/Failure", + "MemberApi/Information/RelatedStudy/Favorite/Failure", getDocumentRequest(), getDocumentResponse(), getHeaderWithAccessToken(), @@ -219,14 +219,14 @@ void throwExceptionByInvalidPermission() throws Exception { } @Test - @DisplayName("사용자가 참여중인 스터디 리스트를 조회한다") + @DisplayName("사용자가 찜한 스터디 리스트를 조회한다") void success() throws Exception { // given given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); given(jwtTokenProvider.getId(anyString())).willReturn(MEMBER_ID); RelatedStudy response = generateRelatedStudyResponse(); - given(memberInformationService.getParticipateStudy(MEMBER_ID)).willReturn(response); + given(memberInformationService.getFavoriteStudy(MEMBER_ID)).willReturn(response); // when MockHttpServletRequestBuilder requestBuilder = RestDocumentationRequestBuilders @@ -238,7 +238,7 @@ void success() throws Exception { .andExpect(status().isOk()) .andDo( document( - "MemberApi/Information/RelatedStudy/Participate/Success", + "MemberApi/Information/RelatedStudy/Favorite/Success", getDocumentRequest(), getDocumentResponse(), getHeaderWithAccessToken(), @@ -246,11 +246,11 @@ void success() throws Exception { parameterWithName("memberId").description("조회할 사용자 ID(PK)") ), responseFields( - fieldWithPath("result[].id").description("참여중인 스터디 ID(PK)"), - fieldWithPath("result[].name").description("참여중인 스터디명"), - fieldWithPath("result[].category").description("참여중인 스터디 카테고리"), - fieldWithPath("result[].thumbnail").description("참여중인 스터디 썸네일 이미지"), - fieldWithPath("result[].thumbnailBackground").description("참여중인 스터디 썸네일 배경색") + fieldWithPath("result[].id").description("찜한 스터디 ID(PK)"), + fieldWithPath("result[].name").description("찜한 스터디명"), + fieldWithPath("result[].category").description("찜한 스터디 카테고리"), + fieldWithPath("result[].thumbnail").description("찜한 스터디 썸네일 이미지"), + fieldWithPath("result[].thumbnailBackground").description("찜한 스터디 썸네일 배경색") ) ) ); @@ -258,58 +258,20 @@ void success() throws Exception { } @Nested - @DisplayName("사용자가 찜한 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/favorite] - AccessToken 필수") - class getFavoriteStudy { - private static final String BASE_URL = "/api/members/{memberId}/studies/favorite"; + @DisplayName("사용자가 참여중인 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/participate]") + class getParticipateStudy { + private static final String BASE_URL = "/api/members/{memberId}/studies/participate"; private static final Long MEMBER_ID = 1L; @Test - @DisplayName("Private한 사용자 정보는 타인이 조회할 수 없다 (Token PayloadId != PathVariable memberId)") - void throwExceptionByInvalidPermission() throws Exception { - // given - given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); - given(jwtTokenProvider.getId(anyString())).willReturn(MEMBER_ID + 10000L); - - // when - MockHttpServletRequestBuilder requestBuilder = RestDocumentationRequestBuilders - .get(BASE_URL, MEMBER_ID) - .header(AUTHORIZATION, String.join(" ", BEARER_TOKEN, ACCESS_TOKEN)); - - // then - final AuthErrorCode expectedError = AuthErrorCode.INVALID_PERMISSION; - mockMvc.perform(requestBuilder) - .andExpectAll( - status().isForbidden(), - jsonPath("$.status").exists(), - jsonPath("$.status").value(expectedError.getStatus().value()), - jsonPath("$.errorCode").exists(), - jsonPath("$.errorCode").value(expectedError.getErrorCode()), - jsonPath("$.message").exists(), - jsonPath("$.message").value(expectedError.getMessage()) - ) - .andDo( - document( - "MemberApi/Information/RelatedStudy/Favorite/Failure", - getDocumentRequest(), - getDocumentResponse(), - getHeaderWithAccessToken(), - pathParameters( - parameterWithName("memberId").description("조회할 사용자 ID(PK)") - ), - getExceptionResponseFiels() - ) - ); - } - - @Test - @DisplayName("사용자가 찜한 스터디 리스트를 조회한다") + @DisplayName("사용자가 참여중인 스터디 리스트를 조회한다") void success() throws Exception { // given given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); given(jwtTokenProvider.getId(anyString())).willReturn(MEMBER_ID); RelatedStudy response = generateRelatedStudyResponse(); - given(memberInformationService.getFavoriteStudy(MEMBER_ID)).willReturn(response); + given(memberInformationService.getParticipateStudy(MEMBER_ID)).willReturn(response); // when MockHttpServletRequestBuilder requestBuilder = RestDocumentationRequestBuilders @@ -321,7 +283,7 @@ void success() throws Exception { .andExpect(status().isOk()) .andDo( document( - "MemberApi/Information/RelatedStudy/Favorite/Success", + "MemberApi/Information/RelatedStudy/Participate", getDocumentRequest(), getDocumentResponse(), getHeaderWithAccessToken(), @@ -329,11 +291,11 @@ void success() throws Exception { parameterWithName("memberId").description("조회할 사용자 ID(PK)") ), responseFields( - fieldWithPath("result[].id").description("찜한 스터디 ID(PK)"), - fieldWithPath("result[].name").description("찜한 스터디명"), - fieldWithPath("result[].category").description("찜한 스터디 카테고리"), - fieldWithPath("result[].thumbnail").description("찜한 스터디 썸네일 이미지"), - fieldWithPath("result[].thumbnailBackground").description("찜한 스터디 썸네일 배경색") + fieldWithPath("result[].id").description("참여중인 스터디 ID(PK)"), + fieldWithPath("result[].name").description("참여중인 스터디명"), + fieldWithPath("result[].category").description("참여중인 스터디 카테고리"), + fieldWithPath("result[].thumbnail").description("참여중인 스터디 썸네일 이미지"), + fieldWithPath("result[].thumbnailBackground").description("참여중인 스터디 썸네일 배경색") ) ) ); @@ -341,7 +303,7 @@ void success() throws Exception { } @Nested - @DisplayName("사용자가 졸업한 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/graduated] - AccessToken 필수") + @DisplayName("사용자가 졸업한 스터디 리스트 조회 API [GET /api/members/{memberId}/studies/graduated]") class getGraduatedStudy { private static final String BASE_URL = "/api/members/{memberId}/studies/graduated"; private static final Long MEMBER_ID = 1L; @@ -396,7 +358,7 @@ void success() throws Exception { } @Nested - @DisplayName("사용자의 피어리뷰 조회 API [GET /api/members/{memberId}/reviews] - AccessToken 필수") + @DisplayName("사용자의 피어리뷰 조회 API [GET /api/members/{memberId}/reviews]") class getReviews { private static final String BASE_URL = "/api/members/{memberId}/reviews"; private static final Long MEMBER_ID = 1L; @@ -437,7 +399,7 @@ void success() throws Exception { } @Nested - @DisplayName("사용자 출석률 조회 API [GET /api/members/{memberId}/attendances] - AccessToken 필수") + @DisplayName("사용자 출석률 조회 API [GET /api/members/{memberId}/attendances]") class getAttendanceRatio { private static final String BASE_URL = "/api/members/{memberId}/attendances"; private static final Long MEMBER_ID = 1L; diff --git a/src/test/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryTest.java b/src/test/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryTest.java index 2bab9e68..1c5eff7c 100644 --- a/src/test/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryTest.java +++ b/src/test/java/com/kgu/studywithme/member/infra/query/MemberSimpleQueryRepositoryTest.java @@ -155,8 +155,8 @@ void findAttendanceRatioByMemberId() { study1.recordAttendance(host, 1, NON_ATTENDANCE); study2.recordAttendance(host, 1, ATTENDANCE); List result1 = memberRepository.findAttendanceRatioByMemberId(host.getId()); + assertThat(result1).hasSize(4); assertAll( - () -> assertThat(result1).hasSize(4), () -> assertThat(findCountByStatus(result1, NON_ATTENDANCE)).isEqualTo(1), () -> assertThat(findCountByStatus(result1, ATTENDANCE)).isEqualTo(1), () -> assertThat(findCountByStatus(result1, LATE)).isEqualTo(0), @@ -167,8 +167,8 @@ void findAttendanceRatioByMemberId() { study1.recordAttendance(host, 2, ATTENDANCE); study2.recordAttendance(host, 2, LATE); List result2 = memberRepository.findAttendanceRatioByMemberId(host.getId()); + assertThat(result2).hasSize(4); assertAll( - () -> assertThat(result2).hasSize(4), () -> assertThat(findCountByStatus(result2, NON_ATTENDANCE)).isEqualTo(1), () -> assertThat(findCountByStatus(result2, ATTENDANCE)).isEqualTo(2), () -> assertThat(findCountByStatus(result2, LATE)).isEqualTo(1), @@ -179,8 +179,8 @@ void findAttendanceRatioByMemberId() { study1.recordAttendance(host, 3, ATTENDANCE); study2.recordAttendance(host, 3, ATTENDANCE); List result3 = memberRepository.findAttendanceRatioByMemberId(host.getId()); + assertThat(result3).hasSize(4); assertAll( - () -> assertThat(result3).hasSize(4), () -> assertThat(findCountByStatus(result3, NON_ATTENDANCE)).isEqualTo(1), () -> assertThat(findCountByStatus(result3, ATTENDANCE)).isEqualTo(4), () -> assertThat(findCountByStatus(result3, LATE)).isEqualTo(1), @@ -191,8 +191,8 @@ void findAttendanceRatioByMemberId() { study1.recordAttendance(host, 4, LATE); study2.recordAttendance(host, 4, ABSENCE); List result4 = memberRepository.findAttendanceRatioByMemberId(host.getId()); + assertThat(result4).hasSize(4); assertAll( - () -> assertThat(result4).hasSize(4), () -> assertThat(findCountByStatus(result4, NON_ATTENDANCE)).isEqualTo(1), () -> assertThat(findCountByStatus(result4, ATTENDANCE)).isEqualTo(4), () -> assertThat(findCountByStatus(result4, LATE)).isEqualTo(2), @@ -203,8 +203,8 @@ void findAttendanceRatioByMemberId() { study1.recordAttendance(host, 5, ABSENCE); study2.recordAttendance(host, 5, NON_ATTENDANCE); List result5 = memberRepository.findAttendanceRatioByMemberId(host.getId()); + assertThat(result5).hasSize(4); assertAll( - () -> assertThat(result5).hasSize(4), () -> assertThat(findCountByStatus(result5, NON_ATTENDANCE)).isEqualTo(2), () -> assertThat(findCountByStatus(result5, ATTENDANCE)).isEqualTo(4), () -> assertThat(findCountByStatus(result5, LATE)).isEqualTo(2), diff --git a/src/test/java/com/kgu/studywithme/study/controller/StudyInformationApiControllerTest.java b/src/test/java/com/kgu/studywithme/study/controller/StudyInformationApiControllerTest.java index 0b83ca49..9c7dc259 100644 --- a/src/test/java/com/kgu/studywithme/study/controller/StudyInformationApiControllerTest.java +++ b/src/test/java/com/kgu/studywithme/study/controller/StudyInformationApiControllerTest.java @@ -28,7 +28,6 @@ import static com.kgu.studywithme.fixture.StudyFixture.TOSS_INTERVIEW; import static com.kgu.studywithme.fixture.WeekFixture.*; import static com.kgu.studywithme.study.domain.attendance.AttendanceStatus.*; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.*; import static com.kgu.studywithme.study.domain.week.submit.UploadType.FILE; import static com.kgu.studywithme.study.domain.week.submit.UploadType.LINK; import static org.mockito.ArgumentMatchers.anyString; @@ -117,11 +116,36 @@ void success() throws Exception { ReviewAssembler response = new ReviewAssembler( 9, List.of( - new ReviewInformation(new StudyMember(1L, "닉네임1"), "리뷰1", LocalDateTime.now().minusDays(1)), - new ReviewInformation(new StudyMember(2L, "닉네임2"), "리뷰2", LocalDateTime.now().minusDays(2)), - new ReviewInformation(new StudyMember(3L, "닉네임3"), "리뷰3", LocalDateTime.now().minusDays(3)), - new ReviewInformation(new StudyMember(4L, "닉네임4"), "리뷰4", LocalDateTime.now().minusDays(4)), - new ReviewInformation(new StudyMember(5L, "닉네임5"), "리뷰5", LocalDateTime.now().minusDays(5)) + new ReviewInformation( + 5L, + "리뷰5", + LocalDateTime.now().minusDays(5), + new StudyMember(1L, "닉네임1") + ), + new ReviewInformation( + 4L, + "리뷰4", + LocalDateTime.now().minusDays(4), + new StudyMember(2L, "닉네임2") + ), + new ReviewInformation( + 3L, + "리뷰3", + LocalDateTime.now().minusDays(3), + new StudyMember(3L, "닉네임3") + ), + new ReviewInformation( + 2L, + "리뷰2", + LocalDateTime.now().minusDays(2), + new StudyMember(4L, "닉네임4") + ), + new ReviewInformation( + 1L, + "리뷰1", + LocalDateTime.now().minusDays(1), + new StudyMember(5L, "닉네임5") + ) ) ); given(studyInformationService.getReviews(STUDY_ID)).willReturn(response); @@ -143,10 +167,11 @@ void success() throws Exception { ), responseFields( fieldWithPath("graduateCount").description("졸업한 사람 수"), - fieldWithPath("reviews[].reviewer.id").description("리뷰어 ID(PK)"), - fieldWithPath("reviews[].reviewer.nickname").description("리뷰어 닉네임"), + fieldWithPath("reviews[].id").description("리뷰 ID(PK)"), fieldWithPath("reviews[].content").description("리뷰 내용"), - fieldWithPath("reviews[].reviewDate").description("리뷰 작성 날짜") + fieldWithPath("reviews[].reviewDate").description("리뷰 작성 날짜"), + fieldWithPath("reviews[].reviewer.id").description("리뷰어 ID(PK)"), + fieldWithPath("reviews[].reviewer.nickname").description("리뷰어 닉네임") .attributes(constraint("날짜 내림차순 정렬로 응답")) ) ) @@ -244,6 +269,7 @@ void success() throws Exception { fieldWithPath("result[].comments[].id").description("공지사항 댓글 ID(PK)"), fieldWithPath("result[].comments[].noticeId").description("공지사항 ID(PK)"), fieldWithPath("result[].comments[].content").description("공지사항 댓글 내용"), + fieldWithPath("result[].comments[].writeDate").description("공지사항 댓글 작성/수정 날짜"), fieldWithPath("result[].comments[].writer.id").description("공지사항 댓글 작성자 ID(PK)"), fieldWithPath("result[].comments[].writer.nickname").description("공지사항 댓글 작성자 닉네임") ) @@ -404,7 +430,7 @@ void success() throws Exception { } @Nested - @DisplayName("스터디 주차별 출석 정보 조회 API [GET /api/studies/{studyId}/attendances] - AccessToken 필수") + @DisplayName("스터디 사용자별 출석 정보 조회 API [GET /api/studies/{studyId}/attendances] - AccessToken 필수") class getAttendances { private static final String BASE_URL = "/api/studies/{studyId}/attendances"; private static final Long STUDY_ID = 1L; @@ -418,7 +444,7 @@ void setUp() { } @Test - @DisplayName("스터디 참여자가 아니라면 스터디 주차별 출석 정보를 조회할 수 없다") + @DisplayName("스터디 참여자가 아니라면 스터디 사용자별 출석 정보를 조회할 수 없다") void throwExceptionByMemberIsNotParticipant() throws Exception { // given given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); @@ -456,7 +482,7 @@ void throwExceptionByMemberIsNotParticipant() throws Exception { } @Test - @DisplayName("스터디 주차별 출석 정보를 조회한다") + @DisplayName("스터디 사용자별 출석 정보를 조회한다") void success() throws Exception { // given given(jwtTokenProvider.isTokenValid(anyString())).willReturn(true); @@ -485,7 +511,6 @@ void success() throws Exception { responseFields( fieldWithPath("result[].member.id").description("스터디 참여자 ID(PK)"), fieldWithPath("result[].member.nickname").description("스터디 참여자 닉네임"), - fieldWithPath("result[].member.participantStatus").description("스터디 참여자 참여 상태"), fieldWithPath("result[].summaries[].week").description("스터디 주차"), fieldWithPath("result[].summaries[].status").description("해당 주차 출석 상태") ) @@ -655,6 +680,7 @@ private NoticeInformation buildNotice(long id) { index, id, "댓글", + LocalDateTime.now().minusDays(index), new StudyMember(generateRandomId(), "댓글작성자") )); } @@ -678,28 +704,18 @@ private AttendanceAssmbler generateStudyAttendances() { List result = new ArrayList<>(); result.add( new StudyMemberAttendanceResult( - new StudyAttendanceMember(1L, "참여자1", APPROVE), + new StudyMember(1L, "참여자1"), List.of( new AttendanceSummary(1, ATTENDANCE.getDescription()), new AttendanceSummary(2, ATTENDANCE.getDescription()), new AttendanceSummary(3, ATTENDANCE.getDescription()), - new AttendanceSummary(4, NON_ATTENDANCE.getDescription()) + new AttendanceSummary(4, LATE.getDescription()) ) ) ); result.add( new StudyMemberAttendanceResult( - new StudyAttendanceMember(2L, "참여자2", CALCEL), - List.of( - new AttendanceSummary(1, ATTENDANCE.getDescription()), - new AttendanceSummary(2, ATTENDANCE.getDescription()), - new AttendanceSummary(3, LATE.getDescription()) - ) - ) - ); - result.add( - new StudyMemberAttendanceResult( - new StudyAttendanceMember(3L, "참여자3", APPROVE), + new StudyMember(3L, "참여자3"), List.of( new AttendanceSummary(1, ATTENDANCE.getDescription()), new AttendanceSummary(2, ABSENCE.getDescription()), @@ -710,7 +726,7 @@ private AttendanceAssmbler generateStudyAttendances() { ); result.add( new StudyMemberAttendanceResult( - new StudyAttendanceMember(4L, "참여자4", APPROVE), + new StudyMember(4L, "참여자4"), List.of( new AttendanceSummary(1, ATTENDANCE.getDescription()), new AttendanceSummary(2, ATTENDANCE.getDescription()), @@ -719,16 +735,6 @@ private AttendanceAssmbler generateStudyAttendances() { ) ) ); - result.add( - new StudyMemberAttendanceResult( - new StudyAttendanceMember(5L, "참여자5", GRADUATED), - List.of( - new AttendanceSummary(1, ATTENDANCE.getDescription()), - new AttendanceSummary(2, ATTENDANCE.getDescription()), - new AttendanceSummary(3, ATTENDANCE.getDescription()) - ) - ) - ); return new AttendanceAssmbler(result); } diff --git a/src/test/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryTest.java b/src/test/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryTest.java index bd0c118e..c70b8d51 100644 --- a/src/test/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryTest.java +++ b/src/test/java/com/kgu/studywithme/study/infra/query/StudyInformationQueryRepositoryTest.java @@ -11,7 +11,6 @@ import com.kgu.studywithme.study.domain.notice.NoticeRepository; import com.kgu.studywithme.study.domain.notice.comment.Comment; import com.kgu.studywithme.study.domain.notice.comment.CommentRepository; -import com.kgu.studywithme.study.domain.participant.ParticipantStatus; import com.kgu.studywithme.study.domain.week.Week; import com.kgu.studywithme.study.domain.week.WeekRepository; import com.kgu.studywithme.study.domain.week.attachment.Attachment; @@ -31,8 +30,6 @@ import static com.kgu.studywithme.fixture.StudyFixture.SPRING; import static com.kgu.studywithme.fixture.WeekFixture.*; import static com.kgu.studywithme.study.domain.attendance.AttendanceStatus.*; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.APPROVE; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.GRADUATED; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; @@ -168,7 +165,6 @@ void findAttendanceByStudyId() { result1, List.of(1, 1, 1, 1), List.of(host, members[0], members[1], members[2]), - List.of(APPROVE, APPROVE, APPROVE, APPROVE), List.of(ATTENDANCE, ATTENDANCE, LATE, ABSENCE) ); @@ -188,20 +184,52 @@ void findAttendanceByStudyId() { assertThatAttendancesMatch( result2, List.of( - 1, 1, 1, 1, - 2, 2, 2, 2 + 1, 2, + 1, 2, + 1, 2, + 2 ), List.of( - host, members[0], members[1], members[2], - host, members[1], members[2], members[3] + host, host, + members[1], members[1], + members[2], members[2], + members[3] ), List.of( - APPROVE, GRADUATED, APPROVE, APPROVE, - APPROVE, APPROVE, APPROVE, APPROVE + ATTENDANCE, LATE, + LATE, ATTENDANCE, + ABSENCE, ATTENDANCE, + ATTENDANCE + ) + ); + + /* 1주차 + 2주차 + 3주차 출석 */ + graduate(members[2]); + applyAttendance( + 3, + Map.of( + host, ATTENDANCE, + members[1], ATTENDANCE, + members[3], ATTENDANCE + ) + ); + List result3 = studyRepository.findAttendanceByStudyId(study.getId()); + assertThatAttendancesMatch( + result3, + List.of( + 1, 2, 3, + 1, 2, 3, + 2, 3 + ), + List.of( + host, host, host, + members[1], members[1], members[1], + members[3], members[3] ), List.of( - ATTENDANCE, ATTENDANCE, LATE, ABSENCE, - LATE, ATTENDANCE, ATTENDANCE, ATTENDANCE + ATTENDANCE, LATE, ATTENDANCE, + LATE, ATTENDANCE, ATTENDANCE, + ATTENDANCE, ATTENDANCE ) ); } @@ -412,7 +440,6 @@ private void assertThatApplicantsMatch(List result, L private void assertThatAttendancesMatch(List result, List weeks, List members, - List participantStatuses, List attendanceStatuses) { int totalSize = attendanceStatuses.size(); assertThat(result).hasSize(totalSize); @@ -421,13 +448,11 @@ private void assertThatAttendancesMatch(List result, AttendanceInformation information = result.get(i); int week = weeks.get(i); Member member = members.get(i); - ParticipantStatus participantStatus = participantStatuses.get(i); AttendanceStatus attendanceStatus = attendanceStatuses.get(i); assertAll( () -> assertThat(information.getParticipant().id()).isEqualTo(member.getId()), () -> assertThat(information.getParticipant().nickname()).isEqualTo(member.getNicknameValue()), - () -> assertThat(information.getParticipant().participantStatus()).isEqualTo(participantStatus), () -> assertThat(information.getWeek()).isEqualTo(week), () -> assertThat(information.getAttendanceStatus()).isEqualTo(attendanceStatus.getDescription()) ); diff --git a/src/test/java/com/kgu/studywithme/study/service/StudyInformationServiceTest.java b/src/test/java/com/kgu/studywithme/study/service/StudyInformationServiceTest.java index 1ff8d155..4d20f814 100644 --- a/src/test/java/com/kgu/studywithme/study/service/StudyInformationServiceTest.java +++ b/src/test/java/com/kgu/studywithme/study/service/StudyInformationServiceTest.java @@ -7,7 +7,6 @@ import com.kgu.studywithme.study.domain.attendance.AttendanceStatus; import com.kgu.studywithme.study.domain.notice.Notice; import com.kgu.studywithme.study.domain.notice.comment.Comment; -import com.kgu.studywithme.study.domain.participant.ParticipantStatus; import com.kgu.studywithme.study.domain.week.Week; import com.kgu.studywithme.study.domain.week.submit.UploadAssignment; import com.kgu.studywithme.study.infra.query.dto.response.CommentInformation; @@ -28,7 +27,6 @@ import static com.kgu.studywithme.fixture.StudyFixture.SPRING; import static com.kgu.studywithme.fixture.WeekFixture.*; import static com.kgu.studywithme.study.domain.attendance.AttendanceStatus.*; -import static com.kgu.studywithme.study.domain.participant.ParticipantStatus.APPROVE; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertAll; @@ -256,12 +254,6 @@ void getAttendances() { AttendanceAssmbler result1 = studyInformationService.getAttendances(study.getId()); assertThatAttendancesMatch( result1.result(), - Map.of( - host.getId(), APPROVE, - members[0].getId(), APPROVE, - members[1].getId(), APPROVE, - members[2].getId(), APPROVE - ), Map.of( host.getId(), List.of(ATTENDANCE), members[0].getId(), List.of(ATTENDANCE), @@ -286,13 +278,6 @@ void getAttendances() { AttendanceAssmbler result2 = studyInformationService.getAttendances(study.getId()); assertThatAttendancesMatch( result2.result(), - Map.of( - host.getId(), APPROVE, - members[0].getId(), APPROVE, - members[1].getId(), APPROVE, - members[2].getId(), APPROVE, - members[3].getId(), APPROVE - ), Map.of( host.getId(), List.of(ATTENDANCE, ATTENDANCE), members[0].getId(), List.of(ATTENDANCE, LATE), @@ -564,16 +549,12 @@ private void assertThatApplicantsMatch(List result, L } private void assertThatAttendancesMatch(List result, - Map expectParticipantStatuses, Map> expectAttendanceStatuses) { for (StudyMemberAttendanceResult studyMemberAttendanceResult : result) { - // check ParticipantStatus - StudyAttendanceMember member = studyMemberAttendanceResult.member(); - assertThat(member.participantStatus()).isEqualTo(expectParticipantStatuses.get(member.id())); - - // check AttendanceStatus + StudyMember member = studyMemberAttendanceResult.member(); List summaries = studyMemberAttendanceResult.summaries(); List attendanceStatuses = expectAttendanceStatuses.get(member.id()); + for (int i = 0; i < summaries.size(); i++) { AttendanceSummary attendanceSummary = summaries.get(i); AttendanceStatus attendanceStatus = attendanceStatuses.get(i);