diff --git a/src/main/java/org/swmaestro/repl/gifthub/auth/dto/UserInfoResponseDto.java b/src/main/java/org/swmaestro/repl/gifthub/auth/dto/UserInfoResponseDto.java index eb426c57..b89965e0 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/auth/dto/UserInfoResponseDto.java +++ b/src/main/java/org/swmaestro/repl/gifthub/auth/dto/UserInfoResponseDto.java @@ -11,14 +11,18 @@ @Getter @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class UserInfoResponseDto { + private Long id; private String username; private String nickname; private List oauth; + public boolean allowNotifications; @Builder - public UserInfoResponseDto(String username, String nickname, List oauth) { + public UserInfoResponseDto(Long id, String username, String nickname, List oauth, boolean allowNotifications) { + this.id = id; this.username = username; this.nickname = nickname; this.oauth = oauth; + this.allowNotifications = allowNotifications; } } diff --git a/src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceTokenRepository.java b/src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceTokenRepository.java index d6302f64..732a206c 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceTokenRepository.java +++ b/src/main/java/org/swmaestro/repl/gifthub/auth/repository/DeviceTokenRepository.java @@ -13,4 +13,6 @@ public interface DeviceTokenRepository extends JpaRepository Optional findByUserAndToken(User user, String token); List findAllByUser(User user); + + Optional findByUser(User user); } diff --git a/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java b/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java index 18a30dbf..c4e26cf2 100644 --- a/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java +++ b/src/main/java/org/swmaestro/repl/gifthub/auth/service/UserService.java @@ -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; @@ -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() @@ -174,10 +176,19 @@ public List 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(); + } } \ No newline at end of file