From 7c5916d00fcf1bc14868e32b15a0a382661b2542 Mon Sep 17 00:00:00 2001 From: its-sky Date: Thu, 11 Jan 2024 17:36:06 +0900 Subject: [PATCH] =?UTF-8?q?[Add]=20#62=20:=20=EB=8C=80=EC=8B=9C=EB=B3=B4?= =?UTF-8?q?=EB=93=9C=EC=97=90=EC=84=9C=20=EC=A1=B0=ED=9A=8C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20Objective=EC=9D=98=20Tree=EB=A5=BC=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8A=94=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/objective/controller/ObjectiveController.java | 5 +++-- .../server/domain/objective/service/ObjectiveService.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/moonshot/server/domain/objective/controller/ObjectiveController.java b/src/main/java/org/moonshot/server/domain/objective/controller/ObjectiveController.java index 669300f8..c1108e8d 100644 --- a/src/main/java/org/moonshot/server/domain/objective/controller/ObjectiveController.java +++ b/src/main/java/org/moonshot/server/domain/objective/controller/ObjectiveController.java @@ -1,5 +1,6 @@ package org.moonshot.server.domain.objective.controller; +import jakarta.annotation.Nullable; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -48,8 +49,8 @@ public ApiResponse modifyObjective(Principal principal, @RequestBody ModifyOb } @GetMapping - public ApiResponse getObjectiveInDashboard(Principal principal) { - DashboardResponseDto response = objectiveService.getObjectiveInDashboard(JwtTokenProvider.getUserIdFromPrincipal(principal)); + public ApiResponse getObjectiveInDashboard(Principal principal, @Nullable @RequestParam("objectiveId") Long objectiveId) { + DashboardResponseDto response = objectiveService.getObjectiveInDashboard(JwtTokenProvider.getUserIdFromPrincipal(principal), objectiveId); return ApiResponse.success(SuccessType.GET_OKR_LIST_SUCCESS, response); } diff --git a/src/main/java/org/moonshot/server/domain/objective/service/ObjectiveService.java b/src/main/java/org/moonshot/server/domain/objective/service/ObjectiveService.java index f426823b..1722a1ed 100644 --- a/src/main/java/org/moonshot/server/domain/objective/service/ObjectiveService.java +++ b/src/main/java/org/moonshot/server/domain/objective/service/ObjectiveService.java @@ -78,9 +78,10 @@ public void modifyObjective(Long userId, ModifyObjectiveRequestDto request) { } } - public DashboardResponseDto getObjectiveInDashboard(Long userId) { + public DashboardResponseDto getObjectiveInDashboard(Long userId, Long objectiveId) { List objList = objectiveRepository.findAllByUserId(userId); - Objective objective = objectiveRepository.findByIdWithKeyResultsAndTasks(objList.get(0).getId()) + Long treeId = objectiveId == null ? objList.get(0).getId() : objectiveId; + Objective objective = objectiveRepository.findByIdWithKeyResultsAndTasks(treeId) .orElseThrow(ObjectiveNotFoundException::new); if (!objective.getUser().getId().equals(userId)) { throw new AccessDeniedException();