Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]액션 플랜 스크랩 토글 기능 API #75

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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