Skip to content

Commit

Permalink
feat: modify read-my-info method
Browse files Browse the repository at this point in the history
  • Loading branch information
inh2613 committed Oct 20, 2023
1 parent 148a271 commit 33c6d12
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.swmaestro.repl.gifthub.auth.dto.UserUpdateResponseDto;
import org.swmaestro.repl.gifthub.auth.entity.OAuth;
import org.swmaestro.repl.gifthub.auth.entity.User;
import org.swmaestro.repl.gifthub.auth.repository.DeviceTokenRepository;
import org.swmaestro.repl.gifthub.auth.repository.UserRepository;
import org.swmaestro.repl.gifthub.auth.type.OAuthPlatform;
import org.swmaestro.repl.gifthub.exception.BusinessException;
Expand All @@ -34,6 +35,7 @@ public class UserService implements UserDetailsService {
private final UserRepository userRepository;
private final PasswordEncoder passwordEncoder;
private final OAuthService oAuthService;
private final DeviceTokenRepository deviceTokenRepository;

public User passwordEncryption(User user) {
return User.builder()
Expand Down Expand Up @@ -174,10 +176,19 @@ public List<OAuth> deleteOAuthInfo(User user) {
public UserInfoResponseDto readInfo(String username) {
User user = read(username);
UserInfoResponseDto userInfoResponseDto = UserInfoResponseDto.builder()
.id(user.getId())
.username(username)
.nickname(user.getNickname())
.oauth(oAuthService.list(user))
.allowNotifications(isExistDeviceToken(user))
.build();
return userInfoResponseDto;
}

/**
* DeviceToken 조회 메서드 (user)
*/
public boolean isExistDeviceToken(User user) {
return deviceTokenRepository.findByUser(user).isPresent();
}
}

0 comments on commit 33c6d12

Please sign in to comment.