From dd676e0878b59ab49b77fdd43b1d082dec1c8c92 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Fri, 5 Jan 2024 05:57:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[FEAT]=20#54=20=EC=94=A8=EC=95=97=20?= =?UTF-8?q?=EC=9E=A0=EA=B8=88=20=ED=95=B4=EC=A0=9C=20API=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/seed/controller/SeedController.java | 8 ++++++++ .../com/example/growthookserver/api/seed/domain/Seed.java | 2 ++ .../api/seed/service/Impl/SeedServiceImpl.java | 7 +++++++ .../growthookserver/api/seed/service/SeedService.java | 2 ++ .../growthookserver/common/response/SuccessStatus.java | 1 + 5 files changed, 20 insertions(+) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java index 00f9c58..0c4b4dc 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/controller/SeedController.java @@ -94,4 +94,12 @@ public ApiResponse getSeedAlarm(@PathVariable Long memb return ApiResponse.success(SuccessStatus.GET_SEED_ALARM, seedService.getSeedAlarm(memberId)); } + @PatchMapping("seed/{seedId}/lock/status") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "unlockSeed", description = "인사이트 잠금을 해제하는 API입니다.") + public ApiResponse unlockSeed(@PathVariable Long seedId) { + seedService.unlockSeed(seedId); + return ApiResponse.success(SuccessStatus.UNLOCK_SEED.getStatusCode(), SuccessStatus.UNLOCK_SEED.getMessage()); + } + } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java index 5082f8a..b572498 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/domain/Seed.java @@ -74,4 +74,6 @@ public void changeCave(Cave newCave) { } public void toggleScrapStatus() { this.isScraped = !this.isScraped; } + + public void unlockSeed() { this.isLocked = false; } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index 0e68bf2..2c47a74 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -118,6 +118,13 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { return SeedAlarmGetResponseDto.of(seedCount); } + @Override + @Transactional + public void unlockSeed(Long seedId) { + Seed seed = seedRepository.findSeedByIdOrThrow(seedId); + seed.unlockSeed(); + } + @Override @Transactional public void toggleSeedScrapStatus(Long seedId) { diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java index 563a51e..d3458a8 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/SeedService.java @@ -40,4 +40,6 @@ public interface SeedService { //* 씨앗 알림 조회 SeedAlarmGetResponseDto getSeedAlarm(Long memberId); + //* 씨앗 잠금 해제 + void unlockSeed(Long seedId); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java index 20c7627..e5e154e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java +++ b/growthookServer/src/main/java/com/example/growthookserver/common/response/SuccessStatus.java @@ -37,6 +37,7 @@ public enum SuccessStatus { GET_SEED_LIST(HttpStatus.OK, "전체 씨앗 리스트 조회 성공" ), TOGGLE_SEED_SCRAP_STATUS(HttpStatus.OK, "씨앗 스크랩 여부 토글 전환 성공"), GET_SEED_ALARM(HttpStatus.OK,"씨앗 알람 조회 성공"), + UNLOCK_SEED(HttpStatus.OK, "씨앗 잠금 해제 성공"), /** * actionplan From 59e0a8070397f77aa90d50ba4d805a827ab1cf00 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Fri, 5 Jan 2024 07:14:03 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[ADD]=20=EC=94=A8=EC=95=97=20=EC=9E=A0?= =?UTF-8?q?=EA=B8=88=20=ED=95=B4=EC=A0=9C=20=EC=8B=9C,=20=EC=88=98?= =?UTF-8?q?=ED=99=95=ED=95=9C=20=EC=91=A5=EC=9D=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/growthookserver/api/member/domain/Member.java | 5 +++++ .../api/seed/service/Impl/SeedServiceImpl.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java index 7d567eb..3ce450c 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/member/domain/Member.java @@ -56,4 +56,9 @@ public Member(String nickname, String email, SocialPlatform socialPlatform, Bool public void incrementGatheredSsuk() { this.gatheredSsuk = (this.gatheredSsuk == null ? 0 : this.gatheredSsuk) + 1; } + + public void useSsuck() { + this.gatheredSsuk--; + this.usedSsuk++; + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java index 2c47a74..a5b8a2e 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/seed/service/Impl/SeedServiceImpl.java @@ -4,6 +4,8 @@ import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository; import com.example.growthookserver.api.cave.domain.Cave; import com.example.growthookserver.api.cave.repository.CaveRepository; +import com.example.growthookserver.api.member.domain.Member; +import com.example.growthookserver.api.member.repository.MemberRepository; import com.example.growthookserver.api.seed.domain.Seed; import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto; import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto; @@ -35,6 +37,7 @@ public class SeedServiceImpl implements SeedService { private final CaveRepository caveRepository; private final SeedRepository seedRepository; private final ActionPlanRepository actionPlanRepository; + private final MemberRepository memberRepository; @Override @Transactional @@ -123,6 +126,10 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) { public void unlockSeed(Long seedId) { Seed seed = seedRepository.findSeedByIdOrThrow(seedId); seed.unlockSeed(); + + Long memberId = seed.getMemberId(); + Member member = memberRepository.findMemberByIdOrThrow(memberId); + member.useSsuck(); } @Override