diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java index b24130f..e51a494 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/controller/ActionPlanController.java @@ -82,4 +82,12 @@ public ApiResponse getDoingActionPlan(@PathVariab public ApiResponse getFinishedActionPlan(@PathVariable Long memberId) { return ApiResponse.success(SuccessStatus.GET_FINISHED_ACTIONPLAN_SUCCESS, actionPlanService.getFinishedActionPlan(memberId)); } + + @PatchMapping("actionplan/{actionplanId}/scrap") + @ResponseStatus(HttpStatus.OK) + @Operation(summary = "ScrapedActionPlan", description = "액션 플랜을 스크랩 하는 API입니다.") + public ApiResponse toggleActionPlanScrapStatus(@PathVariable Long actionplanId) { + actionPlanService.toggleActionPlanScrapStatus(actionplanId); + return ApiResponse.success(SuccessStatus.TOGGLE_ACTIONPLAN_SCRAP.getStatusCode(), SuccessStatus.TOGGLE_SEED_SCRAP_STATUS.getMessage()); + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/domain/ActionPlan.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/domain/ActionPlan.java index 6300441..b25eb22 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/domain/ActionPlan.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/domain/ActionPlan.java @@ -52,4 +52,8 @@ public void updateActionPlan(String newContent) { public void completeActionPlan(Boolean newIsFinished) { this.isFinished = newIsFinished; } + + public void toggleScrapStatus() { + this.isScraped = !this.isScraped; + } } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java index d4f71a5..021abdb 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/ActionPlanService.java @@ -32,4 +32,6 @@ public interface ActionPlanService { //* 완료한 액션 플랜 목록 조회 List getFinishedActionPlan(Long memberId); + + void toggleActionPlanScrapStatus(Long actionpalnId); } diff --git a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java index f1c540e..cf8f648 100644 --- a/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java +++ b/growthookServer/src/main/java/com/example/growthookserver/api/actionplan/service/Impl/ActionPlanServiceImpl.java @@ -110,4 +110,11 @@ public List getFinishedActionPlan(Long memberI .map(actionPlan -> FinishedActionPlanGetResponseDto.of(actionPlan.getId(), actionPlan.getContent(), actionPlan.getIsScraped(),actionPlan.getSeed().getId())) .collect(Collectors.toList()); } + + @Override + @Transactional + public void toggleActionPlanScrapStatus(Long actionpalnId) { + ActionPlan actionPlan = actionPlanRepository.findActionPlanByIdOrThrow(actionpalnId); + actionPlan.toggleScrapStatus(); + } } 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 db6ce4b..2afd550 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 @@ -50,6 +50,7 @@ public enum SuccessStatus { GET_FINISHED_ACTIONPLAN_PERCENT(HttpStatus.OK, "완료한 액션 플랜 퍼센트 조회 성공"), GET_DOING_ACTIONPLAN_SUCCESS(HttpStatus.OK, "진행 중인 액션 플랜 리스트 조회 성공"), GET_FINISHED_ACTIONPLAN_SUCCESS(HttpStatus.OK,"완료한 액션 플랜 리스트 조회 성공"), + TOGGLE_ACTIONPLAN_SCRAP(HttpStatus.OK, "액션 플랜 스크랩 여부 토글 전환 성공"), /** * review