Skip to content

Commit

Permalink
[FEAT]액션 플랜 스크랩 토글 기능 API
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong0329 committed Jan 15, 2024
1 parent 860ac65 commit 5b79cce
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ public ApiResponse<DoingActionPlanGetResponseDto> getDoingActionPlan(@PathVariab
public ApiResponse<FinishedActionPlanGetResponseDto> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public void updateActionPlan(String newContent) {
public void completeActionPlan(Boolean newIsFinished) {
this.isFinished = newIsFinished;
}

public void toggleScrapStatus() {
this.isScraped = !this.isScraped;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ public interface ActionPlanService {

//* 완료한 액션 플랜 목록 조회
List<FinishedActionPlanGetResponseDto> getFinishedActionPlan(Long memberId);

void toggleActionPlanScrapStatus(Long actionpalnId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,11 @@ public List<FinishedActionPlanGetResponseDto> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5b79cce

Please sign in to comment.