-
Notifications
You must be signed in to change notification settings - Fork 1
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: 나의 기록 조회 V2 작업(퍼센테이지 값 추가) #299
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 5 additions & 10 deletions
15
src/main/java/com/dnd/runus/presentation/v1/member/dto/response/MyProfileResponse.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,17 +1,12 @@ | ||
package com.dnd.runus.presentation.v1.member.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record MyProfileResponse( | ||
@Schema(description = "현재 프로필 이미지") | ||
String profileImageUrl, | ||
@Schema(description = "현재 레벨 이름") | ||
String currentLevelName, | ||
@Schema(description = "지금까지 달린 거리") | ||
String currentKm, | ||
@Schema(description = "다음 레벨 이름") | ||
String nextLevelName, | ||
@Schema(description = "다음 레벨까지 남은 거리") | ||
String nextLevelKm | ||
long currentLevel, | ||
int currentExpMeter, | ||
long nextLevel, | ||
int nextLevelStartExpMeter, | ||
int nextLevelEndExpMeter | ||
) { | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/dnd/runus/presentation/v1/member/dto/response/MyProfileResponseV1.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,29 @@ | ||
package com.dnd.runus.presentation.v1.member.dto.response; | ||
|
||
import com.dnd.runus.domain.level.Level; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record MyProfileResponseV1( | ||
@Schema(description = "현재 프로필 이미지") | ||
String profileImageUrl, | ||
@Schema(description = "현재 레벨 이름") | ||
String currentLevelName, | ||
@Schema(description = "지금까지 달린 거리") | ||
String currentKm, | ||
@Schema(description = "다음 레벨 이름") | ||
String nextLevelName, | ||
@Schema(description = "다음 레벨까지 남은 거리") | ||
String nextLevelKm | ||
) { | ||
|
||
public static MyProfileResponseV1 from(MyProfileResponse myProfileResponse) { | ||
return new MyProfileResponseV1( | ||
myProfileResponse.profileImageUrl(), | ||
Level.formatLevelName(myProfileResponse.currentLevel()), | ||
Level.formatExp(myProfileResponse.currentExpMeter()), | ||
Level.formatLevelName(myProfileResponse.nextLevel()), | ||
Level.formatExp(myProfileResponse.nextLevelEndExpMeter() | ||
- myProfileResponse.currentExpMeter()) | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/com/dnd/runus/presentation/v2/member/MemberProfileControllerV2.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,32 @@ | ||
package com.dnd.runus.presentation.v2.member; | ||
|
||
import com.dnd.runus.application.member.MemberService; | ||
import com.dnd.runus.presentation.annotation.MemberId; | ||
import com.dnd.runus.presentation.v1.member.dto.response.MyProfileResponse; | ||
import com.dnd.runus.presentation.v2.member.dto.response.MyProfileResponseV2; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("api/v2/members/profiles") | ||
public class MemberProfileControllerV2 { | ||
private final MemberService memberService; | ||
|
||
@GetMapping("me") | ||
@ResponseStatus(HttpStatus.OK) | ||
public MyProfileResponseV2 getMyProfile(@MemberId long memberId) { | ||
MyProfileResponse myProfile = memberService.getMyProfile(memberId); | ||
|
||
// 퍼센테이지 | ||
double leftNextLevelKm = myProfile.nextLevelEndExpMeter() - myProfile.currentExpMeter(); | ||
double divisor = myProfile.nextLevelEndExpMeter() - myProfile.nextLevelStartExpMeter(); | ||
double percentage = 1 - (leftNextLevelKm / divisor); | ||
|
||
return MyProfileResponseV2.of(myProfile, percentage); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/dnd/runus/presentation/v2/member/dto/response/MyProfileResponseV2.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,36 @@ | ||
package com.dnd.runus.presentation.v2.member.dto.response; | ||
|
||
|
||
import com.dnd.runus.domain.level.Level; | ||
import com.dnd.runus.presentation.v1.member.dto.response.MyProfileResponse; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
public record MyProfileResponseV2 ( | ||
@Schema(description = "현재 프로필 이미지") | ||
String profileImageUrl, | ||
@Schema(description = "현재 레벨 이름") | ||
String currentLevelName, | ||
@Schema(description = "지금까지 달린 거리") | ||
String currentKm, | ||
@Schema(description = "다음 레벨 이름") | ||
String nextLevelName, | ||
@Schema(description = "다음 레벨까지 남은 거리") | ||
String nextLevelKm, | ||
@Schema(description = "퍼센테이지값", example = "0.728") | ||
double percentage | ||
|
||
) { | ||
|
||
public static MyProfileResponseV2 of(MyProfileResponse myProfileResponse, double percentage) { | ||
return new MyProfileResponseV2( | ||
myProfileResponse.profileImageUrl(), | ||
Level.formatLevelName(myProfileResponse.currentLevel()), | ||
Level.formatExp(myProfileResponse.currentExpMeter()), | ||
Level.formatLevelName(myProfileResponse.nextLevel()), | ||
Level.formatExp(myProfileResponse.nextLevelEndExpMeter() | ||
- myProfileResponse.currentExpMeter()), | ||
percentage | ||
); | ||
} | ||
|
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
나중에 service 계층에서는 presentation에 의존하지 않도록 따로 수정하면 좋을 것 같아요!
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.
#301 이슈에서 해당 작업을 진행합니다.