Last active
September 4, 2021 16:18
-
-
Save mseemann/91eaf0efb3dfb6b6a988bd18580d0fd2 to your computer and use it in GitHub Desktop.
SyncToPostgresService
This file contains hidden or 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
@Service | |
@Slf4j | |
@Transactional(propagation = Propagation.REQUIRED) | |
@AllArgsConstructor | |
public class SyncToPostgresService { | |
UserEntityRepository userEntityRepository; | |
ResumeTokenRepository resumeTokenRepository; | |
public void syncInASingleTx(User document, String bookmarkToken, Long tokenTimeStamp) { | |
log.info("syncing to db: {}, with token: {}", document, bookmarkToken); | |
var token = ResumeTokenEntity.builder() | |
.collection(ResumeTokenRepository.USER_COLLECTION) | |
.token(bookmarkToken) | |
.tokenTimeStamp(tokenTimeStamp) | |
.build(); | |
var entity = UserEntity.builder() | |
.id(document.id()) | |
.userName(document.userName() | |
.build(); | |
userEntityRepository.save(entity); | |
resumeTokenRepository.save(token); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment