Skip to content

Commit

Permalink
[refactor] 기획명세서에 맞춰 Soptamp 수정 (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlarlgnszx committed Jan 19, 2025
1 parent dc47bbe commit 35bd47d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 48 deletions.
30 changes: 21 additions & 9 deletions src/main/java/org/sopt/app/presentation/user/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import jakarta.validation.Valid;
import java.time.LocalDate;
import java.util.List;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.sopt.app.application.fortune.FortuneService;
import org.sopt.app.application.playground.dto.PlaygroundProfileInfo.PlaygroundProfile;
import org.sopt.app.application.soptamp.SoptampUserService;
import org.sopt.app.domain.entity.User;
Expand All @@ -26,6 +28,7 @@
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
Expand All @@ -40,6 +43,8 @@ public class UserController {
private final AuthFacade authFacade;
private final PokeFacade pokeFacade;
private final RankFacade rankFacade;
private final FortuneService fortuneService;

@Value("${sopt.current.generation}")
private Long generation;

Expand All @@ -52,10 +57,10 @@ public class UserController {
public ResponseEntity<UserResponse.Soptamp> getSoptampInfo(@AuthenticationPrincipal User user) {
val soptampUser = soptampUserService.getSoptampUserInfo(user.getId());
val response = UserResponse.Soptamp.builder()
.nickname(soptampUser.getNickname())
.profileMessage(soptampUser.getProfileMessage())
.points(soptampUser.getTotalPoints())
.build();
.nickname(soptampUser.getNickname())
.profileMessage(soptampUser.getProfileMessage())
.points(soptampUser.getTotalPoints())
.build();
return ResponseEntity.ok(response);
}

Expand All @@ -69,10 +74,11 @@ public ResponseEntity<UserResponse.ProfileMessage> editProfileMessage(
@AuthenticationPrincipal User user,
@Valid @RequestBody UserRequest.EditProfileMessageRequest editProfileMessageRequest
) {
val result = soptampFacade.editSoptampUserProfileMessage(user.getId(), editProfileMessageRequest.getProfileMessage());
val result = soptampFacade.editSoptampUserProfileMessage(user.getId(),
editProfileMessageRequest.getProfileMessage());
val response = UserResponse.ProfileMessage.builder()
.profileMessage(result.getProfileMessage())
.build();
.profileMessage(result.getProfileMessage())
.build();
return ResponseEntity.ok(response);
}

Expand All @@ -82,19 +88,25 @@ public ResponseEntity<UserResponse.ProfileMessage> editProfileMessage(
@ApiResponse(responseCode = "500", description = "server error", content = @Content)
})
@GetMapping(value = "/sopt-log")
public ResponseEntity<UserResponse.SoptLog> getUserSoptLog(@AuthenticationPrincipal User user) {
public ResponseEntity<UserResponse.SoptLog> getUserSoptLog(
@AuthenticationPrincipal User user, @RequestParam(required = false, value = "ko") boolean partTypeToKorean
) {
int soptLevel = authFacade.getUserSoptLevel(user);
Long pokeCount = pokeFacade.getUserPokeCount(user.getId());
PlaygroundProfile playgroundProfile = authFacade.getUserDetails(user);
Long soptampRank = null;
Long soptDuring = null;
Boolean isActive = playgroundProfile.getLatestActivity().getGeneration() == generation;
boolean isFortuneChecked = fortuneService.isExistTodayFortune((user.getId()));
String fortuneText = isFortuneChecked?fortuneService.getTodayFortuneWordByUserId(user.getId(), LocalDate.now()).title():"오늘 내 운세는?";
if (isActive) {
soptampRank = rankFacade.findUserRank(user.getId());
} else {
soptDuring = authFacade.getDuration(playgroundProfile.getLatestActivity().getGeneration(), generation);
}
List<String> icons = authFacade.getIcons(isActive ? IconType.ACTIVE : IconType.INACTIVE);
return ResponseEntity.ok(SoptLog.of(soptLevel, pokeCount, soptampRank, soptDuring,isActive,icons, playgroundProfile));
return ResponseEntity.ok(
SoptLog.of(soptLevel, pokeCount, soptampRank, soptDuring, isActive, icons, playgroundProfile,
partTypeToKorean,isFortuneChecked, fortuneText));
}
}
86 changes: 47 additions & 39 deletions src/main/java/org/sopt/app/presentation/user/UserResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import lombok.ToString;
import org.sopt.app.application.app_service.dto.AppServiceInfo;
import org.sopt.app.application.playground.dto.PlaygroundProfileInfo.PlaygroundProfile;
import org.sopt.app.domain.enums.PlaygroundPart;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class UserResponse {
Expand Down Expand Up @@ -110,43 +109,52 @@ public static AppService of(final AppServiceInfo appServiceInfo) {
}
}

@Getter
@Builder
public static class SoptLog {
@Schema(description = "유저 이름", example = "차은우")
private String userName;
@Schema(description = "프로필 이미지 url", example = "www.png")
private String profileImage;
@Schema(description = "파트")
private PlaygroundPart part;
@Schema(description = "콕찌르기 횟수")
private String pokeCount;
@Schema(description = "", example = "14등")
private String soptampRank;
@Schema(description = "솝력 ", example = "LV.7")
private String soptLevel;
@Schema(description = "유저 소개", example = "false")
private String profileMessage;
@Schema(description = "솝트와", example = "37개월")
private String during;
private List<String> icons;
private Boolean isActive;

public static SoptLog of(int soptLevel, Long pokeCount, Long soptampRank, Long during, Boolean isActive,
List<String> icons,
PlaygroundProfile playgroundProfile) {
return SoptLog.builder()
.soptLevel("Lv." + soptLevel)
.pokeCount(pokeCount + "회")
.soptampRank(soptampRank != null ? soptampRank +"등" : null)
.userName(playgroundProfile.getName())
.profileImage(playgroundProfile.getProfileImage())
.part(playgroundProfile.getLatestActivity().getPlaygroundPart())
.profileMessage(playgroundProfile.getIntroduction())
.during(during != null ? during + "개월": null)
.isActive(isActive)
.icons(icons)
.build();
}
@Getter
@Builder
public static class SoptLog {
@Schema(description = "유저 이름", example = "차은우")
private String userName;
@Schema(description = "프로필 이미지 url", example = "www.png")
private String profileImage;
@Schema(description = "파트")
private String part;
@Schema(description = "콕찌르기 횟수")
private String pokeCount;
@Schema(description = "", example = "14등")
private String soptampRank;
@Schema(description = "솝력 ", example = "LV.7")
private String soptLevel;
@Schema(description = "유저 소개", example = "false")
private String profileMessage;
@Schema(description = "솝트와", example = "37개월")
private String during;
@Schema(description = "아이콘 리스트", example = "['www.png']")
private List<String> icons;
@Schema(description = "활동 기수 여부", example = "true")
private Boolean isActive;
@Schema(description = "운세 체크 여부", example = "true")
private Boolean isFortuneChecked;
@Schema(description = "오늘의 운세", example = "오늘은 좋은 날이에요!")
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) {
return SoptLog.builder()
.soptLevel("Lv." + soptLevel)
.pokeCount(pokeCount + "회")
.soptampRank(soptampRank != null ? soptampRank + "등" : null)
.userName(playgroundProfile.getName())
.profileImage(playgroundProfile.getProfileImage())
.part(partTypeToKorean?playgroundProfile.getLatestActivity().getPlaygroundPart().getPartName():playgroundProfile.getLatestActivity().getPlaygroundPart().toString())
.profileMessage(playgroundProfile.getIntroduction())
.during(during != null ? during + "개월" : null)
.isActive(isActive)
.icons(icons)
.isFortuneChecked(isFortuneChecked)
.todayFortuneText(fortuneText)
.build();
}
}
}

0 comments on commit 35bd47d

Please sign in to comment.