/tasks/{taskId}/attachments)@PostMapping(value = "/tasks/{taskId}/attachments", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<?> upload(@PathVariable("taskId") Long taskId,
@RequestParam("files") List<MultipartFile> files,
Authentication auth) {
// 현재 로그인한 사용자의 ID 추출
Long uploaderId = Long.valueOf(auth.getName());
// AttachmentService에서 실제 파일 저장 처리 후 결과 반환
return ResponseEntity.ok(attachmentService.uploadToTask(taskId, uploaderId, files));
}
설명:
ApiException 발생 → 글로벌 핸들러 처리consumes = MULTIPART_FORM_DATA_VALUE → multipart/form-data 형식만 허용/attachments/{attachmentId})@DeleteMapping("/attachments/{attachmentId}")
public ResponseEntity<?> delete(@PathVariable("attachmentId") Long attachmentId,
Authentication auth) {
Long requesterId = Long.valueOf(auth.getName());
// 실제 삭제 로직은 softDelete 메서드에서 처리 (DB flag 변경)
attachmentService.softDelete(attachmentId, requesterId);
return ResponseEntity.ok().build();
}
설명: