Skip to content

Commit

Permalink
refactor: TokenInfo를 record로 변경한다
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Mar 10, 2024
1 parent 38990cb commit 1a98784
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void THROW_EXCEPTION_WHEN_TOKEN_IS_NULL_OR_EMPTY(String token) {

private void assertDecryptedInfo(TokenInfo response, String expectedName, Long expectedUserId,
Long expectedTargetId) {
Assertions.assertEquals(response.getUserId(), expectedUserId);
Assertions.assertEquals(response.getTargetId(), expectedTargetId);
Assertions.assertEquals(response.userId(), expectedUserId);
Assertions.assertEquals(response.targetId(), expectedTargetId);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package me.nalab.user.application.common.dto;

import lombok.Data;

@Data
public class TokenInfo {

private final Long targetId;
private final Long userId;
public record TokenInfo(
Long targetId,
Long userId
) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public LoginedInfo getLoginedInfoByToken(String encryptedToken) {
String[] split = encryptedToken.split(" ");
throwIfInvalidToken(split);
var tokenInfo = loginedUserGetByTokenPort.decryptToken(split[1]);
var user = userGetPort.getById(tokenInfo.getUserId());
return LoginedInfo.from(tokenInfo.getTargetId(), user);
var user = userGetPort.getById(tokenInfo.userId());
return LoginedInfo.from(tokenInfo.targetId(), user);
}

private void throwIfInvalidToken(String[] split) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public class UserDeleteService implements UserDeleteUseCase {
@Transactional
public void deleteByToken(String token) {
var tokenInfo = loginedUserGetByTokenPort.decryptToken(token);
userDeletePort.deleteUserById(tokenInfo.getUserId());
userDeletePort.deleteUserById(tokenInfo.userId());
}
}

0 comments on commit 1a98784

Please sign in to comment.