-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [STMT-290] 단일 스터디 멤버 조회 API 구현 (#151)
* ✨ [STMT-290] 단일 스터디 멤버 조회 쿼리 구현 * ✨ [STMT-290] 멤버의 활동 참여 목록 쿼리 구현 * ✨ [STMT-290] 활동 상태와 활동 참여자 도메인에 성취 판단 여부를 반환하는 메서드 구현 * ✨ [STMT-290] 멤버의 성취도를 계산하는 유스케이스 구현 * ✨ [STMT-290] 스터디 멤버 상세 조회 유스케이스 구현 * ✨ [STMT-290] 스터디 멤버 상세 조회 API 구현 * 🐛 [STMT-290] 포도알 발송 여부를 포도알 발송 가능 여부로 수정 * ✅ [STMT-290] 스터디 멤버 상세 조회 성공 테스트 케이스 작성 * ✅ [STMT-290] 스터디 멤버 상세 조회 실패 테스트 케이스 작성 * 📝 [STMT-290] 스터디 멤버 목록/상세 조회 API 테스트 문서에 header 정보 추가 * 📝 [STMT-290] 스터디 멤버 상세 조회 API 명세서 작성
- Loading branch information
Showing
21 changed files
with
346 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ava/com/stumeet/server/activity/application/port/in/EvaluateMemberAchievementUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.stumeet.server.activity.application.port.in; | ||
|
||
public interface EvaluateMemberAchievementUseCase { | ||
|
||
Integer getMemberAchievement(Long studyId, Long memberId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...stumeet/server/activity/application/service/EvaluateMemberMemberParticipationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.stumeet.server.activity.application.service; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.stumeet.server.activity.application.port.in.EvaluateMemberAchievementUseCase; | ||
import com.stumeet.server.activity.application.port.out.ActivityParticipantQueryPort; | ||
import com.stumeet.server.activity.domain.model.ActivityCategory; | ||
import com.stumeet.server.activity.domain.model.ActivityParticipant; | ||
import com.stumeet.server.activity.domain.model.CommonStatus; | ||
import com.stumeet.server.common.annotation.UseCase; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class EvaluateMemberMemberParticipationService implements EvaluateMemberAchievementUseCase { | ||
private static final int PERCENTAGE_MULTIPLIER = 100; | ||
|
||
private final ActivityParticipantQueryPort activityParticipantQueryPort; | ||
|
||
@Override | ||
public Integer getMemberAchievement(Long studyId, Long memberId) { | ||
List<ActivityParticipant> activityParticipants = | ||
activityParticipantQueryPort.findMemberParticipation(studyId, memberId); | ||
|
||
return calculateParticipationPercentage(activityParticipants); | ||
} | ||
|
||
private Integer calculateParticipationPercentage(List<ActivityParticipant> participants) { | ||
List<ActivityParticipant> joinedActivities = getValidJoinedActivities(participants); | ||
long totalActivities = joinedActivities.size(); | ||
|
||
if (totalActivities == 0) { | ||
return 0; | ||
} | ||
|
||
long achievedActivities = joinedActivities.stream() | ||
.filter(ActivityParticipant::isAchieved) | ||
.count(); | ||
|
||
double participation = (double)achievedActivities / totalActivities * PERCENTAGE_MULTIPLIER; | ||
return (int)participation; | ||
} | ||
|
||
private List<ActivityParticipant> getValidJoinedActivities(List<ActivityParticipant> participants) { | ||
return participants.stream() | ||
.filter(participant -> isValidCategory(participant) && hasJoined(participant)) | ||
.toList(); | ||
} | ||
|
||
private boolean isValidCategory(ActivityParticipant participant) { | ||
return participant.getActivity().getCategory().equals(ActivityCategory.ASSIGNMENT) | ||
|| participant.getActivity().getCategory().equals(ActivityCategory.MEET); | ||
} | ||
|
||
private boolean hasJoined(ActivityParticipant participant) { | ||
return !participant.getStatus().equals(CommonStatus.NOT_JOINED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...main/java/com/stumeet/server/studymember/application/port/in/StudyMemberQueryUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package com.stumeet.server.studymember.application.port.in; | ||
|
||
import com.stumeet.server.studymember.application.port.in.response.StudyMemberDetailResponse; | ||
import com.stumeet.server.studymember.application.port.in.response.StudyMemberResponses; | ||
|
||
public interface StudyMemberQueryUseCase { | ||
StudyMemberResponses getStudyMembers(Long studyId, Long memberId); | ||
StudyMemberResponses getStudyMembers(Long studyId, Long requesterId); | ||
|
||
StudyMemberDetailResponse getStudyMemberDetail(Long studyId, Long targetMemberId, Long requesterId); | ||
} |
12 changes: 12 additions & 0 deletions
12
...om/stumeet/server/studymember/application/port/in/response/StudyMemberDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.stumeet.server.studymember.application.port.in.response; | ||
|
||
public record StudyMemberDetailResponse( | ||
Long id, | ||
String name, | ||
String image, | ||
String region, | ||
String profession, | ||
boolean canSendGrape, | ||
Integer achievement | ||
) { | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/stumeet/server/studymember/application/port/out/StudyMemberQueryPort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
package com.stumeet.server.studymember.application.port.out; | ||
|
||
import com.stumeet.server.studymember.application.port.in.response.SimpleStudyMemberResponse; | ||
import com.stumeet.server.studymember.domain.StudyMember; | ||
|
||
import java.util.List; | ||
|
||
public interface StudyMemberQueryPort { | ||
List<SimpleStudyMemberResponse> findStudyMembers(Long studyId); | ||
|
||
StudyMember findStudyMember(Long studyId, Long memberId); | ||
|
||
boolean isSentGrape(Long studyId, Long memberId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.