-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] 솝트 로그 API 개발 - #437 #459
base: dev
Are you sure you want to change the base?
Changes from 1 commit
60b5574
0214a15
a463d50
4dc67dc
4650d69
dfcdef3
9b607fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package org.sopt.app.facade; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.sopt.app.application.auth.JwtTokenService; | ||
import org.sopt.app.application.auth.dto.PlaygroundAuthTokenInfo.AppToken; | ||
|
@@ -11,6 +12,7 @@ | |
import org.sopt.app.application.soptamp.SoptampUserService; | ||
import org.sopt.app.application.user.UserService; | ||
import org.sopt.app.domain.entity.User; | ||
import org.sopt.app.domain.enums.IconType; | ||
import org.sopt.app.presentation.auth.AppAuthRequest.AccessTokenRequest; | ||
import org.sopt.app.presentation.auth.AppAuthRequest.CodeRequest; | ||
import org.sopt.app.presentation.auth.AppAuthResponse; | ||
|
@@ -79,4 +81,12 @@ public int getUserSoptLevel(User user) { | |
public PlaygroundProfile getUserDetails(User user) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P4. user를 매개변수로 전달하는 것이 아닌 필요한 playgroundToken만 전달하는 것이 좋을 것 같아요 |
||
return playgroundAuthService.getPlayGroundProfile(user.getPlaygroundToken()); | ||
} | ||
|
||
public Long getDuration(Long Mygeneration, Long generation) { | ||
return userService.getDuration(Mygeneration, generation); | ||
} | ||
|
||
public List<String> getIcons(IconType iconType) { | ||
return userService.getIcons(iconType); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,20 @@ | |
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement; | ||
import jakarta.validation.Valid; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.sopt.app.application.playground.dto.PlaygroundProfileInfo.PlaygroundProfile; | ||
import org.sopt.app.application.soptamp.SoptampUserService; | ||
import org.sopt.app.domain.entity.User; | ||
import org.sopt.app.domain.enums.IconType; | ||
import org.sopt.app.facade.AuthFacade; | ||
import org.sopt.app.facade.PokeFacade; | ||
import org.sopt.app.facade.RankFacade; | ||
import org.sopt.app.facade.SoptampFacade; | ||
import org.sopt.app.presentation.user.UserResponse.SoptLog; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
@@ -37,6 +40,8 @@ public class UserController { | |
private final AuthFacade authFacade; | ||
private final PokeFacade pokeFacade; | ||
private final RankFacade rankFacade; | ||
@Value("${sopt.current.generation}") | ||
private Long generation; | ||
|
||
@Operation(summary = "솝탬프 정보 조회") | ||
@ApiResponses({ | ||
|
@@ -80,8 +85,16 @@ public ResponseEntity<UserResponse.ProfileMessage> editProfileMessage( | |
public ResponseEntity<UserResponse.SoptLog> getUserSoptLog(@AuthenticationPrincipal User user) { | ||
int soptLevel = authFacade.getUserSoptLevel(user); | ||
Long pokeCount = pokeFacade.getUserPokeCount(user.getId()); | ||
Long soptampRank = rankFacade.findUserRank(user.getId()); | ||
PlaygroundProfile playgroundProfile = authFacade.getUserDetails(user); | ||
return ResponseEntity.ok(SoptLog.of(soptLevel, pokeCount, soptampRank, playgroundProfile)); | ||
Long soptampRank = null; | ||
Long soptDuring = null; | ||
Comment on lines
+89
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2. Long 값을 null로 전달하는 것보다 isActive 값에 따라서 ResponseEntity를 return하는 것이 좋아보여요. |
||
Boolean isActive = playgroundProfile.getLatestActivity().getGeneration() == generation; | ||
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)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2. 현재 홈화면에서 사용되는 ActivityDurationCalculator 사용하면 될 것 같습니다!