-
Notifications
You must be signed in to change notification settings - Fork 1
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
fcmToken 등록 및 업데이트 api 구현 #74
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
fcm 토큰 등록하는 로직을 하나의 api로 통합하셨는데 이전의 구현 로직(회원가입, 로그인)에서 제거된 커밋이 보이지 않는 것 같아요 확인부탁드립니다
그리고 토큰 삭제는 이전의 로직을 그대로 사용하나요? (로그아웃 api에서 토큰을 헤더로 받아서 삭제 처리하는)
src/test/resources/schema.sql~HEAD
Outdated
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.
파일 지워주세요!
}) | ||
UserFcmToken toEntity(User user, String fcmToken, LocalDate createdAt); | ||
UserFcmToken toEntity(User user, String fcmToken, String device_id); |
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.
P3) camel case로 변경 부탁드립니당
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.
수정하겠습니다 !!
private String fcmToken; | ||
public class UserFcmToken extends BaseEntity { | ||
@EmbeddedId | ||
private FcmId fcmId; |
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.
P3) fcmId를 getter로 노출시키지 않으려면 처리가 필요할 것 같아요
private FcmId fcmId; | |
@Getter(AccessLevel.PRIVATE) | |
private FcmId fcmId; |
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.
그렇네요 ! 수정하겠습니다 :)
User user = userSearchService.findUserByOauthId(oauthId); | ||
userFcmTokenRepository.save(notificationMapper.toEntity(user, fcmToken, LocalDate.now())); | ||
UserFcmToken userFcmToken = notificationMapper.toEntity(user, request.fcmToken(), request.deviceId()); | ||
Optional<UserFcmToken> exitsFcmToken = userFcmTokenRepository.findUserFcmTokenByFcmId(oauthId, request.deviceId()); |
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.
exists의 오타라서 존재하는 토큰이라는 의미인지 종료된 토큰이라는 의미인지 불분명한 것 같아요 어떤 의미의 변수명인가요?
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.
존재하는 토큰입니다 ! ㅜ 오타 수정하겠습니다 !
UserFcmToken userFcmToken = notificationMapper.toEntity(user, request.fcmToken(), request.deviceId()); | ||
Optional<UserFcmToken> exitsFcmToken = userFcmTokenRepository.findUserFcmTokenByFcmId(oauthId, request.deviceId()); | ||
if (exitsFcmToken.isEmpty()) { | ||
userFcmTokenRepository.save(userFcmToken); |
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.
P3) return;
을 사용해서 else문을 제거해보는 건 어떨까요??
* @since 1.1.0 | ||
*/ | ||
public void saveFcmToken(String fcmToken, String oauthId) { | ||
public void saveFcmToken(FcmTokenRequest request, String oauthId) { |
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.
P3) 기존의 fcm 토큰을 업데이트하는 로직을 먼저 실행하면 불필요한 user 조회 쿼리를 줄일 수 있을 것 같아요 그리고 두 개의 책임을 지고 있는데 리팩토링할 때 메서드를 분리해보면 어떨까 싶습니다!
if(fcmToken.isPresent()) {
토큰 업데이트();
return;
}
새로운 토큰 저장();
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.
기존에 존재하는 userFcmToken을 조회하기 위해 oauthId에 대한 검증이 필요하다고 생각했지만, oauthId는 이미 filter에서 검증된 유저임으로 조회가 필요 없을 것 같군요..! 수정하겠습니다 👍
`CREATED_AT` date NOT NULL, | ||
PRIMARY KEY (`FCM_TOKEN`), | ||
`DEVICE_ID` varchar(255) NOT NULL, | ||
`CREATED_AT` date NOT NULL, |
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.
BaseEntity 클래스는 LocalDateTime 타입의 필드를 제공하도록 구현해두었어요 date 타입으로 스키마를 작성하신 이유가 있을까요??
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.
재사용을 위해 기존의 BaseEntity를 사용하긴 했지만 userFcmToken에서는 date만 필요하기 때문에, time은 불필요하다고 생각했습니다
public class UserFcmToken { | ||
@Id | ||
private String fcmToken; | ||
public class UserFcmToken extends BaseEntity { |
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.
Persistable 인터페이스 구현하지 않아도 save할 때 잘 작동하나요??
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.
persistable을 통해 새로운 엔티티 여부를 판별하지 않고, select를 통해 새로운 엔티티를 판별합니다.
업데이트 시, 기존에 조회된 엔티티가 있을 경우, 더티 체킹을 통해 변경된 부분을 업데이트하기 때문에 잘 작동하고 있습니다 !
This comment has been minimized.
This comment has been minimized.
기존 커밋에서 로그인, 회원가입 Service에 또한 토큰 삭제는 이전과 동일하게 로그아웃을 통해 삭제되지만 header 대신 body로 받을 수 있게 수정하였습니다 ! |
Analysis Details0 IssuesCoverage and DuplicationsProject ID: co-niverse_dangjang-backend_AYj2jZJELehUZAlqDvRk |
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.
LGTM~
Changes 📝
fcmToken 등록 및 업데이트 api 구현
Details 🌼
Check List ☑️
Etc