-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add notification agreement field in user-info-dto #131
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 순환참조 문제(UserService와 DevicetokenService)가 발생해서 DeviceRepository를 두번 의존성 주입을 했습니다. 스프링 컨테이너는 싱글톤 범위로 빈을 관리하므로, DeviceTokenRepository는 하나의 인스턴스만 생성되고, 그 인스턴스가 DeviceTokenService 및 UserService에 주입된다고 하긴 해서 우선 이렇게 진행하긴 했는데, 이 방법 말고 어떻게 해결할 수 있을지 궁금합니다. ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 지난 번 순환 참조 문제가 발생했던 적이 있었습니다. 순환 참조 문제를 해결하기 가장 좋은 방법은 예전에 제가 순환 참조를 해결하면서 작성했던 문서가 있는데 가볍게 읽어보시면 좋을 것 같습니다! 현재 구현해주신 코드가 개발 진행 속도를 고려한다면 어쩔 수 없는 선택이라고 생각합니다. |
||
|
||
public User passwordEncryption(User user) { | ||
return User.builder() | ||
|
@@ -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(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P5 : id를 Dto에 추가하신 이유가 궁금합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클라이언트에서 요청하여 추가하였습니다. 슬랙 스레드에 댓글로 언급되어 있어서 확인 못 하셨나봅니다!