-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
128 additions
and
111 deletions.
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
3 changes: 2 additions & 1 deletion
3
src/main/java/org/hankki/hankkiserver/api/auth/controller/request/UserLoginRequest.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,10 +1,11 @@ | ||
package org.hankki.hankkiserver.api.auth.controller.request; | ||
|
||
import jakarta.annotation.Nullable; | ||
import org.hankki.hankkiserver.domain.user.model.Platform; | ||
|
||
public record UserLoginRequest( | ||
@Nullable | ||
String name, | ||
String platform | ||
Platform platform | ||
) { | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/org/hankki/hankkiserver/api/auth/service/UserAdapter.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,40 @@ | ||
package org.hankki.hankkiserver.api.auth.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.common.code.ErrorCode; | ||
import org.hankki.hankkiserver.common.exception.EntityNotFoundException; | ||
import org.hankki.hankkiserver.domain.user.model.Platform; | ||
import org.hankki.hankkiserver.domain.user.model.User; | ||
import org.hankki.hankkiserver.domain.user.repository.UserRepository; | ||
import org.hankki.hankkiserver.external.openfeign.dto.SocialInfoDto; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static org.hankki.hankkiserver.domain.user.model.MemberStatus.ACTIVE; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserAdapter { | ||
|
||
private final UserRepository userRepository; | ||
|
||
public User getUser(final Platform platform, final String serialId) { | ||
return userRepository.findByPlatformAndSerialIdAndMemberStatus(platform, serialId, ACTIVE) | ||
.orElseThrow(() -> new EntityNotFoundException(ErrorCode.USER_NOT_FOUND)); | ||
} | ||
|
||
public User getUser(final long userId) { | ||
return userRepository.findByIdAndMemberStatus(userId, ACTIVE) | ||
.orElseThrow(() -> new EntityNotFoundException(ErrorCode.USER_NOT_FOUND)); | ||
} | ||
|
||
public boolean isRegisteredUser(final Platform platform, final SocialInfoDto socialInfo) { | ||
return userRepository.existsByPlatformAndSerialIdAndMemberStatus( | ||
platform, | ||
socialInfo.serialId(), | ||
ACTIVE); | ||
} | ||
|
||
public void saveUser(final User user) { | ||
userRepository.save(user); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/org/hankki/hankkiserver/api/auth/service/UserInfoAdapter.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 org.hankki.hankkiserver.api.auth.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.hankki.hankkiserver.common.code.ErrorCode; | ||
import org.hankki.hankkiserver.common.exception.EntityNotFoundException; | ||
import org.hankki.hankkiserver.domain.user.model.UserInfo; | ||
import org.hankki.hankkiserver.domain.user.repository.UserInfoRepository; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserInfoAdapter { | ||
|
||
private final UserInfoRepository userInfoRepository; | ||
|
||
public UserInfo getUserInfo(final long userId) { | ||
return userInfoRepository.findByUserId(userId) | ||
.orElseThrow(() -> new EntityNotFoundException(ErrorCode.USER_INFO_NOT_FOUND)); | ||
} | ||
|
||
public void saveUserInfo(final UserInfo userInfo) { | ||
userInfoRepository.save(userInfo); | ||
} | ||
|
||
public void softDelete(final long userId) { | ||
userInfoRepository.softDeleteByUserId(userId); | ||
} | ||
|
||
} |
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
Oops, something went wrong.