Skip to content

Commit

Permalink
Merge pull request #63 from MOONSHOT-Team/feature/#62
Browse files Browse the repository at this point in the history
[Add] #62 : 대시보드에서 조회하는 Objective의 Tree를 선택할 수 있는 기능 추가
  • Loading branch information
its-sky authored Jan 11, 2024
2 parents f54afe1 + 7c5916d commit 3dbf1c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -48,8 +49,8 @@ public ApiResponse<?> modifyObjective(Principal principal, @RequestBody ModifyOb
}

@GetMapping
public ApiResponse<DashboardResponseDto> getObjectiveInDashboard(Principal principal) {
DashboardResponseDto response = objectiveService.getObjectiveInDashboard(JwtTokenProvider.getUserIdFromPrincipal(principal));
public ApiResponse<DashboardResponseDto> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ public void modifyObjective(Long userId, ModifyObjectiveRequestDto request) {
}
}

public DashboardResponseDto getObjectiveInDashboard(Long userId) {
public DashboardResponseDto getObjectiveInDashboard(Long userId, Long objectiveId) {
List<Objective> 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();
Expand Down

0 comments on commit 3dbf1c1

Please sign in to comment.