TaskCommandService, TaskQueryService) 호출@AuthenticationPrincipal로 가져옴ApiException 등으로 처리하고, 글로벌 핸들러에서 JSON 응답으로 통일GET /api/tasks)@GetMapping
public ResponseEntity<PageResponse<TaskResponse>> list(
@RequestParam(name = "scope", required = false, defaultValue = "all") String scope,
@RequestParam(name = "status", required = false) TaskStatus status,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "size", required = false, defaultValue = "9") int size,
@AuthenticationPrincipal UserDetails principal
) {
Long userId = Long.parseLong(principal.getUsername());
Page<TaskResponse> result = taskQueryService.list(scope, status, userId, page, size);
return ResponseEntity.ok(PageResponse.from(result));
}
설명:
scope: 조회 범위 (all, my, dept)status: 업무 상태 필터 (TODO, IN_PROGRESS, DONE 등)page / size: 페이징 처리principal)에서 userId 가져와 서비스 호출PageResponse<TaskResponse> 형태 → 클라이언트에서 페이징 UI 사용 가능POST /api/tasks/create)@PostMapping("/create")
public ResponseEntity<TaskResponse> create(
@Valid @RequestBody TaskCreateRequest req,
@AuthenticationPrincipal UserDetails principal
) {
if (principal == null) return ResponseEntity.status(401).build();
Long userId = Long.parseLong(principal.getUsername());
return ResponseEntity.ok(taskCommandService.create(req, userId));
}
설명:
TaskCreateRequest로 업무 정보 전달