Skip to content

Commit

Permalink
[TDC-38] stickerCount 비즈니스 로직에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yerimkoko committed Jan 9, 2024
1 parent 4ad43a6 commit 0b81a7e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class StickerReactionService {

private final ReactionRepository reactionRepository;

private final StickerRepository stickerRepository;

private final StickerCountRepository stickerCountRepository;
Expand All @@ -33,10 +34,15 @@ public void upsertSticker(AddReactionRequest request, StickerGroup stickerGroup)

Reaction reaction = reactionRepository.getByReactionStickerGroupAndTargetIdAndAccountId(stickerGroup, request.getTargetId(), request.getAccountId());
if (reaction != null) {
reaction.getStickerIds()
.forEach(id -> stickerCountRepository.decrByCount(stickerGroup, reaction.getTargetId(), id));
request.getStickerIds()
.forEach(id -> stickerCountRepository.incrByCount(stickerGroup, request.getTargetId(), id));
reaction.update(request.getStickerIds());
return;
}

request.getStickerIds()
.forEach(id -> stickerCountRepository.incrByCount(stickerGroup, request.getTargetId(), id));
reactionRepository.save(Reaction.newInstance(stickerGroup, stickerList, request.getAccountId(), request.getTargetId()));

}
Expand Down

0 comments on commit 0b81a7e

Please sign in to comment.