-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat - 유저 정보 불러오기 기능 구현
- Loading branch information
Showing
13 changed files
with
91 additions
and
65 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
src/main/java/sopt/org/HMH/domain/challenge/dto/request/ChallengeRequest.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
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
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
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
8 changes: 4 additions & 4 deletions
8
src/main/java/sopt/org/HMH/domain/user/dto/response/LoginResponse.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
15 changes: 15 additions & 0 deletions
15
src/main/java/sopt/org/HMH/domain/user/dto/response/UserInfoResponse.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,15 @@ | ||
package sopt.org.HMH.domain.user.dto.response; | ||
|
||
import sopt.org.HMH.domain.user.domain.User; | ||
|
||
public record UserInfoResponse( | ||
String name, | ||
Integer point | ||
) { | ||
public static UserInfoResponse of(User user) { | ||
return new UserInfoResponse( | ||
user.getName(), | ||
user.getPoint() | ||
); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
package sopt.org.HMH.global.common; | ||
|
||
import java.security.Principal; | ||
import sopt.org.HMH.global.auth.jwt.exception.JwtError; | ||
import sopt.org.HMH.global.auth.jwt.exception.JwtException; | ||
|
||
import static java.util.Objects.isNull; | ||
|
||
public class Util { | ||
// public static Long getUserId(Principal principal) { | ||
// if (isNull(principal)) { | ||
// throw new SecurityException(EMPTY_ACCESS_TOKEN.getMessage()); | ||
// } | ||
// return Long.valueOf(principal.getName()); | ||
// } | ||
|
||
/** | ||
* Principal 객체로부터 User의 식별자를 추출하는 메서드 | ||
*/ | ||
public static Long getUserId(Principal principal) { | ||
if (isNull(principal)) { | ||
throw new JwtException(JwtError.EMPTY_PRINCIPLE_EXCEPTION); | ||
} | ||
return Long.valueOf(principal.getName()); | ||
} | ||
} |