Skip to content

Commit

Permalink
refactor: 지도 답장 편지 작성 시, 답장 대상에게 알림 전송
Browse files Browse the repository at this point in the history
  • Loading branch information
hgh1472 committed Dec 8, 2024
1 parent 4f80b64 commit b8c2acf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public List<MapLetterAndDistance> findLettersByUserLocation(BigDecimal latitude,
}

@Override
public void findSourceMapLetterById(Long sourceMapLetterId) {
public MapLetter findSourceMapLetterById(Long sourceMapLetterId) {
MapLetterEntity activeLetter = mapLetterJpaRepository.findActiveById(sourceMapLetterId);
if (activeLetter == null) {
throw new SourceMapLetterNotFountException("원본 편지를 찾을 수 없습니다. 편지가 존재하지 않거나 삭제되었습니다.");
}
return MapLetterEntity.toDomain(activeLetter);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface MapLetterRepository {

List<MapLetterAndDistance> findLettersByUserLocation(BigDecimal latitude, BigDecimal longitude, Long userId);

void findSourceMapLetterById(Long sourceMapLetterId);
MapLetter findSourceMapLetterById(Long sourceMapLetterId);

void letterBlock(Long letterId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,12 @@ public ReplyMapLetter createReplyMapLetter(@Valid CreateReplyMapLetterRequestDTO
throw new LetterAlreadyReplyException("해당 편지에 이미 답장을 했습니다.");
}

mapLetterRepository.findSourceMapLetterById(createReplyMapLetterRequestDTO.sourceLetter());
MapLetter source = mapLetterRepository.findSourceMapLetterById(createReplyMapLetterRequestDTO.sourceLetter());
ReplyMapLetter replyMapLetter = ReplyMapLetter.createReplyMapLetter(createReplyMapLetterRequestDTO, userId);
ReplyMapLetter save = replyMapLetterRepository.save(replyMapLetter);
saveRecentReply(save.getReplyLetterId(), save.getLabel(), save.getSourceLetterId());
notificationService.sendNotification(MAP_REPLY, source.getCreateUserId(), save.getReplyLetterId(),
save.getLabel());
return save;
}

Expand Down

0 comments on commit b8c2acf

Please sign in to comment.