Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
28 changes: 25 additions & 3 deletions src/main/java/org/sopt/app/facade/UserFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand All @@ -114,7 +136,7 @@ public UserResponse.MySoptLog getMySoptLog(Long userId) {
);
}

return UserResponse.MySoptLog.ofInactive(
return UserResponse.MySoptLog.ofInactiveNonAppjam(
isFortuneChecked,
todayFortuneText,
totalPokeCount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public interface AppjamUserRepository extends JpaRepository<AppjamUser, Long> {
List<AppjamUser> findAllByTeamNumberIn(Collection<TeamNumber> teamNumbers);

List<AppjamUser> findAllByUserIdIn(Collection<Long> userIds);

boolean existsByUserId(Long userId);
}
106 changes: 70 additions & 36 deletions src/main/java/org/sopt/app/presentation/user/UserResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -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();
}

}
Expand All @@ -78,9 +78,9 @@ public static class Operation {

public static Operation defaultOperation() {
return Operation.builder()
.attendanceScore(0D)
.announcement("")
.build();
.attendanceScore(0D)
.announcement("")
.build();
}
}

Expand Down Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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<String> icons,
PlaygroundProfile playgroundProfile,boolean partTypeToKorean,
boolean isFortuneChecked, String fortuneText) {
List<String> 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();
}
}

Expand All @@ -203,6 +203,9 @@ public record MySoptLog(
@Schema(description = "활동 기수 여부")
boolean isActive,

@Schema(description = "앱잼 참여 여부")
boolean isAppjamParticipant,

@Schema(description = "오늘의 운세 확인 여부")
boolean isFortuneChecked,

Expand Down Expand Up @@ -234,7 +237,7 @@ public record MySoptLog(
int soulmatesPokeCount
) {

public static MySoptLog ofInactive(
public static MySoptLog ofInactiveNonAppjam(
boolean isFortuneChecked,
String todayFortuneText,
int totalPokeCount,
Expand All @@ -243,6 +246,7 @@ public static MySoptLog ofInactive(
int soulmatesPokeCount
) {
return new MySoptLog(
false,
false,
isFortuneChecked,
todayFortuneText,
Expand All @@ -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,
Expand All @@ -271,6 +304,7 @@ public static MySoptLog ofActive(
) {
return new MySoptLog(
true,
isAppjamParticipant,
isFortuneChecked,
todayFortuneText,
soptampCount,
Expand Down