diff --git a/src/main/java/org/sopt/app/application/appjamuser/AppjamUserService.java b/src/main/java/org/sopt/app/application/appjamuser/AppjamUserService.java index 4db8afad..1e316f7c 100644 --- a/src/main/java/org/sopt/app/application/appjamuser/AppjamUserService.java +++ b/src/main/java/org/sopt/app/application/appjamuser/AppjamUserService.java @@ -26,4 +26,8 @@ public TeamSummary getTeamSummaryByUserId(Long userId) { .orElseThrow(() -> new NotFoundException(ErrorCode.TEAM_NOT_FOUND)); return TeamSummary.from(appjamUser); } + + public boolean isAppjamParticipant(Long userId) { + return appjamUserRepository.existsByUserId(userId); + } } diff --git a/src/main/java/org/sopt/app/facade/UserFacade.java b/src/main/java/org/sopt/app/facade/UserFacade.java index b306b74b..63c10fd0 100755 --- a/src/main/java/org/sopt/app/facade/UserFacade.java +++ b/src/main/java/org/sopt/app/facade/UserFacade.java @@ -4,6 +4,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; +import org.sopt.app.application.appjamuser.AppjamUserService; import org.sopt.app.application.fortune.FortuneService; import org.sopt.app.application.friend.FriendService; import org.sopt.app.application.platform.PlatformService; @@ -40,6 +41,7 @@ public class UserFacade { private final PokeService pokeService; private final FortuneService fortuneService; private final UserService userService; + private final AppjamUserService appjamUserService; @Transactional(readOnly = true) public MainView getMainViewInfo(Long userId) { @@ -81,6 +83,8 @@ public UserResponse.MySoptLog getMySoptLog(Long userId) { UserStatus userStatus = platformService.getStatus(userId); boolean isActive = (userStatus == UserStatus.ACTIVE); + boolean isAppjamParticipant = appjamUserService.isAppjamParticipant(userId); + boolean isFortuneChecked = fortuneService.isExistTodayFortune(userId); String todayFortuneText = isFortuneChecked ? fortuneService.getTodayFortuneWordByUserId(userId, LocalDate.now()).title() @@ -94,13 +98,31 @@ public UserResponse.MySoptLog getMySoptLog(Long userId) { int soulmatesPokeCount = friendService.sumPokeCountByFriendship( userId, Friendship.SOULMATE.getLowerLimit(), Friendship.SOULMATE.getUpperLimit()); - if (isActive) { + boolean isSoptampIncluded = isActive || isAppjamParticipant; + + if (isSoptampIncluded) { int soptampCount = stampService.getCompletedMissionCount(userId); int viewCount = stampService.getTotalViewCount(userId); int myClapCount = stampService.getTotalReceivedClapCount(userId); int clapCount = clapService.getTotalGivenClapCount(userId); - return UserResponse.MySoptLog.ofActive( + if (isActive) { + return UserResponse.MySoptLog.ofActive( + isAppjamParticipant, + isFortuneChecked, + todayFortuneText, + soptampCount, + viewCount, + myClapCount, + clapCount, + totalPokeCount, + newFriendsPokeCount, + bestFriendsPokeCount, + soulmatesPokeCount + ); + } + + return UserResponse.MySoptLog.ofInactiveAppjamParticipant( isFortuneChecked, todayFortuneText, soptampCount, @@ -114,7 +136,7 @@ public UserResponse.MySoptLog getMySoptLog(Long userId) { ); } - return UserResponse.MySoptLog.ofInactive( + return UserResponse.MySoptLog.ofInactiveNonAppjam( isFortuneChecked, todayFortuneText, totalPokeCount, diff --git a/src/main/java/org/sopt/app/interfaces/postgres/AppjamUserRepository.java b/src/main/java/org/sopt/app/interfaces/postgres/AppjamUserRepository.java index 1cda0ccc..e0d67e0e 100644 --- a/src/main/java/org/sopt/app/interfaces/postgres/AppjamUserRepository.java +++ b/src/main/java/org/sopt/app/interfaces/postgres/AppjamUserRepository.java @@ -18,4 +18,6 @@ public interface AppjamUserRepository extends JpaRepository { List findAllByTeamNumberIn(Collection teamNumbers); List findAllByUserIdIn(Collection userIds); + + boolean existsByUserId(Long userId); } diff --git a/src/main/java/org/sopt/app/presentation/user/UserResponse.java b/src/main/java/org/sopt/app/presentation/user/UserResponse.java index 493ae204..ea2915ea 100755 --- a/src/main/java/org/sopt/app/presentation/user/UserResponse.java +++ b/src/main/java/org/sopt/app/presentation/user/UserResponse.java @@ -34,10 +34,10 @@ public static class MainView { public static MainView unauthenticatedMainView() { return MainView.builder() - .user(Playground.unauthenticatedUser()) - .operation(Operation.defaultOperation()) - .isAllConfirm(false) - .build(); + .user(Playground.unauthenticatedUser()) + .operation(Operation.defaultOperation()) + .isAllConfirm(false) + .build(); } } @@ -57,11 +57,11 @@ public static class Playground { public static Playground unauthenticatedUser() { return Playground.builder() - .status("UNAUTHENTICATED") - .name("") - .profileImage("") - .generationList(List.of()) - .build(); + .status("UNAUTHENTICATED") + .name("") + .profileImage("") + .generationList(List.of()) + .build(); } } @@ -78,9 +78,9 @@ public static class Operation { public static Operation defaultOperation() { return Operation.builder() - .attendanceScore(0D) - .announcement("") - .build(); + .attendanceScore(0D) + .announcement("") + .build(); } } @@ -131,10 +131,10 @@ public static class AppService { public static AppService of(final AppServiceInfo appServiceInfo) { return AppService.builder() - .serviceName(appServiceInfo.getServiceName()) - .activeUser(appServiceInfo.getActiveUser()) - .inactiveUser(appServiceInfo.getInactiveUser()) - .build(); + .serviceName(appServiceInfo.getServiceName()) + .activeUser(appServiceInfo.getActiveUser()) + .inactiveUser(appServiceInfo.getInactiveUser()) + .build(); } } @@ -167,26 +167,26 @@ public static class SoptLog { private String todayFortuneText; public static SoptLog of(int soptLevel, Long pokeCount, Long soptampRank, Long during, Boolean isActive, - List icons, - PlaygroundProfile playgroundProfile,boolean partTypeToKorean, - boolean isFortuneChecked, String fortuneText) { + List icons, + PlaygroundProfile playgroundProfile, boolean partTypeToKorean, + boolean isFortuneChecked, String fortuneText) { return SoptLog.builder() - .soptLevel("Lv." + soptLevel) - .pokeCount(pokeCount + "회") - .soptampRank(soptampRank != null ? soptampRank + "등" : "공개 예정!") - .userName(playgroundProfile.getName()) - .profileImage(playgroundProfile.getProfileImage() != null ? playgroundProfile.getProfileImage() : "") - .part(playgroundProfile.getAllActivities().stream() - .map(c -> c.getPlaygroundPart().getPartName()) - .filter(c -> !c.equals(SoptPart.NONE.getPartName())) - .collect(Collectors.joining("/"))) - .profileMessage(playgroundProfile.getIntroduction() != null ? playgroundProfile.getIntroduction() : "") - .during(during != null ? during + "개월" : "") - .isActive(isActive) - .icons(icons) - .isFortuneChecked(isFortuneChecked) - .todayFortuneText(fortuneText) - .build(); + .soptLevel("Lv." + soptLevel) + .pokeCount(pokeCount + "회") + .soptampRank(soptampRank != null ? soptampRank + "등" : "공개 예정!") + .userName(playgroundProfile.getName()) + .profileImage(playgroundProfile.getProfileImage() != null ? playgroundProfile.getProfileImage() : "") + .part(playgroundProfile.getAllActivities().stream() + .map(c -> c.getPlaygroundPart().getPartName()) + .filter(c -> !c.equals(SoptPart.NONE.getPartName())) + .collect(Collectors.joining("/"))) + .profileMessage(playgroundProfile.getIntroduction() != null ? playgroundProfile.getIntroduction() : "") + .during(during != null ? during + "개월" : "") + .isActive(isActive) + .icons(icons) + .isFortuneChecked(isFortuneChecked) + .todayFortuneText(fortuneText) + .build(); } } @@ -203,6 +203,9 @@ public record MySoptLog( @Schema(description = "활동 기수 여부") boolean isActive, + @Schema(description = "앱잼 참여 여부") + boolean isAppjamParticipant, + @Schema(description = "오늘의 운세 확인 여부") boolean isFortuneChecked, @@ -234,7 +237,7 @@ public record MySoptLog( int soulmatesPokeCount ) { - public static MySoptLog ofInactive( + public static MySoptLog ofInactiveNonAppjam( boolean isFortuneChecked, String todayFortuneText, int totalPokeCount, @@ -243,6 +246,7 @@ public static MySoptLog ofInactive( int soulmatesPokeCount ) { return new MySoptLog( + false, false, isFortuneChecked, todayFortuneText, @@ -257,7 +261,36 @@ public static MySoptLog ofInactive( ); } + public static MySoptLog ofInactiveAppjamParticipant( + boolean isFortuneChecked, + String todayFortuneText, + int soptampCount, + int viewCount, + int myClapCount, + int clapCount, + int totalPokeCount, + int newFriendsPokeCount, + int bestFriendsPokeCount, + int soulmatesPokeCount + ) { + return new MySoptLog( + false, + true, + isFortuneChecked, + todayFortuneText, + soptampCount, + viewCount, + myClapCount, + clapCount, + totalPokeCount, + newFriendsPokeCount, + bestFriendsPokeCount, + soulmatesPokeCount + ); + } + public static MySoptLog ofActive( + boolean isAppjamParticipant, boolean isFortuneChecked, String todayFortuneText, int soptampCount, @@ -271,6 +304,7 @@ public static MySoptLog ofActive( ) { return new MySoptLog( true, + isAppjamParticipant, isFortuneChecked, todayFortuneText, soptampCount,