Skip to content

feature: 매칭 수락 거절 분리 추가, 코인 상태 타입 추가 #23

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

Merged
merged 2 commits into from
Apr 9, 2025

Conversation

okluckyok
Copy link
Collaborator

매칭 수락 거절 분리 추가, 코인 상태 타입 추가

@okluckyok okluckyok requested a review from f-lab-nolan March 26, 2025 12:59
@okluckyok okluckyok self-assigned this Mar 26, 2025
matchingeRepository.findByIdAndRecvId(matchingVO.id(), userId)
.map(el -> {
Optional.ofNullable(userServiceClient.viewCoin(userId, authentication))
.filter(coin -> coin >= 10000L)
Copy link
Collaborator

Choose a reason for hiding this comment

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

private void minusCoin(){
Optional.ofNullable(userServiceClient.viewCoin(userId, authentication))
.filter(coin -> coin >= 10000L)
.map(coin -> {
el.setStatusCd("MATCHED");
userServiceClient.updateCoin(userId, authentication, new UserCoinDTO(String.valueOf(userId), -10000L, CoinActionType.CONSUME));
return coin;
})
.orElseThrow(() -> new BusinessException(MessageCode.INSUFFICIENT_COIN));
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

coin = userServiceClient.viewCoin(userId, authentication);
if (coin !=null && coin >= 10000L) {
userServiceClient.updateCoin(userId, authentication, new UserCoinDTO(String.valueOf(userId), -10000L, CoinActionType.CONSUME));
return;
}
new BusinessException(MessageCode.INSUFFICIENT_COIN));

Copy link
Collaborator

Choose a reason for hiding this comment

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

matchingeRepository.findByIdAndRecvId(matchingVO.id(), userId)
.map(el -> {
minusCoin();
el.setStatusCd("MATCHED");
}
.orElseThrow(() -> new BusinessException(MessageCode.MATCHING_NOT_FOUND));
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Obj ojb = matchingeRepository.findByIdAndRecvId(matchingVO.id(), userId).orElseThrow(() -> new BusinessException(MessageCode.MATCHING_NOT_FOUND));
matchingeRepository.delete(obj)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

람다식 이중부분은 단순하게 변경되었습니다

return userCoinRepository.save(new UserCoin(userCoinVO.userId(), userCoinVO.balance()));
});
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

obj = userCoinRepository.findByUserId(userCoinVO.userId());
if obj != null{
l.setBalance(el.getBalance() + userCoinVO.balance());
kafkaProducer.sendMessage("coin-topic", new UserCoinLogVO(userCoinVO.userId(), userCoinVO.balance(), userCoinVO.coinActionType().getCode(), LocalDateTime.now(), userCoinVO.userId()), false);
userCoinRepository.save(el);
return
}

kafkaProducer.sendMessage("coin-topic", new UserCoinLogVO(userCoinVO.userId(), userCoinVO.balance(), userCoinVO.coinActionType().getCode(), LocalDateTime.now(), userCoinVO.userId()), false);
userCoinRepository.save(new UserCoin(userCoinVO.userId(), userCoinVO.balance()));

@okluckyok okluckyok merged commit 838fb4d into main Apr 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants