From a0ffb18a184860078c631ede1529e86ddf2c6486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=EC=8D=A8=ED=81=AC?= Date: Wed, 3 Jan 2024 05:49:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20cycle=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/member/service/MemberService.java | 25 +++++++++++++++++-- .../domain/reward/service/RewardService.java | 20 ++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/teami/domain/member/service/MemberService.java b/src/main/java/com/teami/domain/member/service/MemberService.java index eb66245..3625d8b 100644 --- a/src/main/java/com/teami/domain/member/service/MemberService.java +++ b/src/main/java/com/teami/domain/member/service/MemberService.java @@ -9,6 +9,9 @@ import com.teami.domain.member.dto.response.VisitorCommentRes; import com.teami.domain.member.entitty.Member; import com.teami.domain.member.repository.MemberRepository; +import com.teami.domain.reward.entity.MemberReward; +import com.teami.domain.reward.entity.Reward; +import com.teami.domain.reward.repository.MemberRewardRepository; import com.teami.domain.reward.service.RewardService; import com.teami.global.apiPayload.ExceptionHandler; import com.teami.global.apiPayload.code.status.ErrorStatus; @@ -19,13 +22,16 @@ import java.util.List; import java.util.Optional; +import static com.teami.domain.reward.entity.Reward.*; +import static com.teami.domain.reward.entity.Reward.SIGNUP_AND_CALENDAR_CREATE; + @Service @RequiredArgsConstructor public class MemberService { private final MemberRepository memberRepository; private final FriendRepository friendRepository; private final CalendarVisitorRepository calendarVisitorRepository; - private final RewardService rewardService; + private final MemberRewardRepository memberRewardRepository; public Member findMemberById(Long memberId) { Optional member = memberRepository.findById(memberId); @@ -61,7 +67,13 @@ else if(memberRepository.findMemberByNickname(nickname) != null){ Member member = new Member(memberRequest); memberRepository.save(member); - rewardService.createReward_Member(member); + + createReward_Reward(member); + + if (!memberRewardRepository.existsByMemberAndReward(member, SIGNUP_AND_CALENDAR_CREATE)) { + memberRewardRepository.save(MemberReward.createMemberReward(member, SIGNUP_AND_CALENDAR_CREATE)); + } + return true; } @@ -137,4 +149,13 @@ public String checkFirstLetter(Long memberId) { } return null; } + private Reward createReward_Reward(Member member) { + if (!memberRewardRepository.existsByMemberAndReward(member, COMPLETE_FIRST_MISSION)) { + if (memberRewardRepository.countMemberRewardByMember(member) == 0L) { + memberRewardRepository.save(MemberReward.createMemberReward(member, EARN_FIVE_REWARDS)); + return EARN_FIVE_REWARDS; + } + } + return null; + } } diff --git a/src/main/java/com/teami/domain/reward/service/RewardService.java b/src/main/java/com/teami/domain/reward/service/RewardService.java index ad055d6..4c51c14 100644 --- a/src/main/java/com/teami/domain/reward/service/RewardService.java +++ b/src/main/java/com/teami/domain/reward/service/RewardService.java @@ -82,15 +82,7 @@ public Reward createReward_Mission2(Member member) { return null; } - public Reward createReward_Reward(Member member) { - if (!memberRewardRepository.existsByMemberAndReward(member, COMPLETE_FIRST_MISSION)) { - if (memberRewardRepository.countMemberRewardByMember(member) == 0L) { - memberRewardRepository.save(MemberReward.createMemberReward(member, EARN_FIVE_REWARDS)); - return EARN_FIVE_REWARDS; - } - } - return null; - } + public Reward createReward_Friend1(Member member) { @@ -116,4 +108,14 @@ public Reward createReward_Friend2(Member member) { public List getMyRewardList(Long memberId) { return memberRewardRepository.findByMemberId(memberId); } + + private Reward createReward_Reward(Member member) { + if (!memberRewardRepository.existsByMemberAndReward(member, COMPLETE_FIRST_MISSION)) { + if (memberRewardRepository.countMemberRewardByMember(member) == 0L) { + memberRewardRepository.save(MemberReward.createMemberReward(member, EARN_FIVE_REWARDS)); + return EARN_FIVE_REWARDS; + } + } + return null; + } } \ No newline at end of file