AttachmentService.java

역할


1. 상수 및 필드

private final AttachmentRepository attachmentRepository;  // DB 접근
private final FileStorageService fileStorageService;      // 파일 시스템 접근

// 첨부파일 제한
private static final int MAX_FILES = 10;                   // 한 번에 업로드 가능한 최대 파일 수
private static final long MAX_TOTAL_SIZE = 50L * 1024 * 1024; // 총합 50MB

2. Task별 첨부파일 조회

@Transactional(readOnly = true)
public List<AttachmentResponse> listByTask(Long taskId) {
    return attachmentRepository.findByTaskIdAndIsDeletedFalseOrderByIdDesc(taskId)
                               .stream()
                               .map(AttachmentMapper::toResponse) // Mapper 사용
                               .toList();
}

3. 첨부파일 업로드

@Transactional
public List<AttachmentResponse> uploadToTask(Long taskId, Long uploaderId, List<MultipartFile> files) { ... }