Skip to content
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

[feat #108] 채팅 수락/거절 API #109

Merged
merged 23 commits into from
Sep 18, 2024
Merged

Conversation

hyun2371
Copy link
Member

관련 이슈

📑 작업 상세 내용

  • 채팅 상태 enum 필드 추가
    • 대기, 수락 -> 대기, 수락, 거절
  • 채팅 수락 API
    • 상태 변경 및 답변자 크레딧 증가
  • 채팅 거절 API
    • 상태 변경 및 요청자 크레딧 환불

💫 작업 요약

  • 채팅 수락 API
  • 채팅 거절 API

🔍 중점적으로 리뷰 할 부분

  • 기존에는 채팅 요청 시 요청자 보유 크레딧이 2000 넘는지만 체크했습니다.
    • 답변자의 채팅 요청 수락 시점에 2000 크레딧이 없을 경우를 감안하여
      요청 시 2000 크레딧을 소모하고, 거절 당한 경우 2000을 반환받도록 로직을 수정했습니다.

@hyun2371 hyun2371 added the ✨ feat 기능 추가 label Sep 16, 2024
@hyun2371 hyun2371 requested a review from dudxo September 16, 2024 13:30
@hyun2371 hyun2371 self-assigned this Sep 16, 2024
Copy link

Code Coverage

Overall Project 85.21% -0.51% 🍏
Files changed 84.73% 🍏

File Coverage
ChatRoomController.java 100% 🍏
ChatStatus.java 100% 🍏
ChatRoom.java 83.05% -16.95% 🍏
ChatRoomService.java 81.48% -9.26% 🍏

Copy link

Test Results

 23 files   23 suites   13s ⏱️
108 tests 108 ✅ 0 💤 0 ❌
109 runs  109 ✅ 0 💤 0 ❌

Results for commit ab69788.

Copy link
Collaborator

@dudxo dudxo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추석 연휴에 개발하시느라 수고 많으셨습니다~
크레딧 관련 @transactional의 격리 레벨 변경 또는 lock을 걸어도 좋을 것 같아요

@hyun2371
Copy link
Member Author

hyun2371 commented Sep 17, 2024

추석 연휴에 개발하시느라 수고 많으셨습니다~ 크레딧 관련 @transactional의 격리 레벨 변경 또는 lock을 걸어도 좋을 것 같아요

동시성 제어를 할 필요가 없을 것 같은데, 트랜잭션 레벨 변경이나 락을 걸어야 하는 이유를 알려줄 수 있으실까요??

@dudxo
Copy link
Collaborator

dudxo commented Sep 17, 2024

동시성 제어를 할 필요가 없을 것 같은데, 트랜잭션 레벨 변경이나 락을 걸어야 하는 이유를 알려줄 수 있으실까요??

채팅방 수락 시 채팅방 요청자의 크레딧 -2,000과 채팅방 답변자의 크레딧 +2,000원을 하게 됩니다. 이 때, 다른 로직에서 요청자의 크레딧에 대해 접근을 하게된다면 문제가 발생하지 않을까요?

추가로 답변 작성하면서 다시 확인하니 현재 로직에서는 채팅 수락시 요청자의 크레딧 -2,000원 하는 로직이 빠져있네요!

@hyun2371
Copy link
Member Author

hyun2371 commented Sep 18, 2024

동시성 제어를 할 필요가 없을 것 같은데, 트랜잭션 레벨 변경이나 락을 걸어야 하는 이유를 알려줄 수 있으실까요??

채팅방 수락 시 채팅방 요청자의 크레딧 -2,000과 채팅방 답변자의 크레딧 +2,000원을 하게 됩니다. 이 때, 다른 로직에서 요청자의 크레딧에 대해 접근을 하게된다면 문제가 발생하지 않을까요?

추가로 답변 작성하면서 다시 확인하니 현재 로직에서는 채팅 수락시 요청자의 크레딧 -2,000원 하는 로직이 빠져있네요!

넵 채팅방 생성(채팅 요청) 시 크레딧 감소시키도록 수정했습니다! 채팅을 거절 당하면 2000원을 환급 받는 방식입니다.
일정 기간 내에 수락하지 않으면 자동으로 거절되는 로직을 추후에 추가하면 좋을 것 같아요

@hyun2371 hyun2371 merged commit 2689b75 into dev Sep 18, 2024
3 checks passed
@hyun2371 hyun2371 deleted the feat/#108/accept-reject-chat branch September 18, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feat 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 채팅 수락/거절 API
2 participants