@@ -30,20 +30,17 @@ public class BattleProposalService {
3030 private final CreditService creditService ;
3131 private final UserService userService ;
3232
33- private static final int PROPOSAL_COST = 30 ;
34- private static final int PROPOSAL_REWARD = 100 ;
35-
3633 @ Transactional
3734 public BattleProposalResponse propose (BattleProposalRequest request ) {
3835 User user = userService .findCurrentUser ();
3936
40- // 크레딧 잔액 확인
37+ int cost = CreditType .TOPIC_SUGGEST .getDefaultAmount ();
38+
4139 int totalCredits = creditService .getTotalPoints (user .getId ());
42- if (totalCredits < PROPOSAL_COST ) {
40+ if (totalCredits < cost ) {
4341 throw new CustomException (ErrorCode .CREDIT_NOT_ENOUGH );
4442 }
4543
46- // 제안 저장
4744 BattleProposal proposal = BattleProposal .builder ()
4845 .user (user )
4946 .category (request .getCategory ())
@@ -55,8 +52,7 @@ public BattleProposalResponse propose(BattleProposalRequest request) {
5552
5653 battleProposalRepository .save (proposal );
5754
58- // 30크레딧 차감 (음수로 저장)
59- creditService .addCredit (user .getId (), CreditType .TOPIC_SUGGEST , -PROPOSAL_COST , proposal .getId ());
55+ creditService .addCredit (user .getId (), CreditType .TOPIC_SUGGEST , -cost , proposal .getId ());
6056
6157 return new BattleProposalResponse (proposal );
6258 }
@@ -87,8 +83,8 @@ public BattleProposalResponse review(Long proposalId, BattleProposalReviewReques
8783
8884 if (request .getAction () == BattleProposalReviewRequest .Action .ACCEPT ) {
8985 proposal .accept ();
90- // 100크레딧 지급
91- creditService .addCredit (proposal .getUser ().getId (), CreditType .TOPIC_ADOPTED , PROPOSAL_REWARD , proposalId );
86+ int reward = CreditType . TOPIC_ADOPTED . getDefaultAmount ();
87+ creditService .addCredit (proposal .getUser ().getId (), CreditType .TOPIC_ADOPTED , reward , proposalId );
9288 } else {
9389 proposal .reject ();
9490 }
0 commit comments