Skip to content

[Fix/fix update love point]#23

Merged
ekgns33 merged 2 commits intomainfrom
fix/fix-update-love-point
Apr 4, 2025
Merged

[Fix/fix update love point]#23
ekgns33 merged 2 commits intomainfrom
fix/fix-update-love-point

Conversation

@ekgns33
Copy link
Copy Markdown
Contributor

@ekgns33 ekgns33 commented Apr 4, 2025

애정 부여 시, 기존의 로직에 오류가 있었습니다.
Screenshot 2025-04-04 at 4 09 06 PM

  • AS
    updateLovePoint로 추상화된 로직에 음수값을 전달하지 않던 로직 존재

  • TOBE
    증가 / 감소 메소드를 분리. 모든 parameter에서 양수값만 사용하도록 조정.

 @Transactional
  public LovePoint acquireLovePoint(Long userId, Long loveAmount) {
    LovePoint lp = lovePointRepository.findByUserIdWithXLock(userId)
        .orElseThrow(IllegalStateException::new);
    lp.add(loveAmount);
    return lovePointRepository.save(lp);
  }

  @Transactional
  public LovePoint useLovePoint(Long userId, Long loveAmount) {
    LovePoint lp = lovePointRepository.findByUserIdWithXLock(userId)
        .orElseThrow(IllegalStateException::new);
    lp.subtract(loveAmount);
    return lovePointRepository.save(lp);
  }

@ekgns33 ekgns33 self-assigned this Apr 4, 2025
@ekgns33 ekgns33 added the bug Something isn't working label Apr 4, 2025
@ekgns33 ekgns33 requested a review from jeeheaG April 4, 2025 07:31
@ekgns33 ekgns33 merged commit 19b816c into main Apr 4, 2025
1 check passed
@ekgns33 ekgns33 deleted the fix/fix-update-love-point branch April 16, 2025 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant