1. DTO
1-1. AttachmentResponse.java
public record AttachmentResponse(
Long id, // 첨부파일 고유 ID
String originalFilename, // 사용자가 업로드한 원본 파일명
String contentType, // MIME 타입
Long sizeBytes, // 파일 크기(바이트)
String storagePath // 서버 저장 경로 또는 접근 가능한 URL
) {}
- 역할: DB/Service → Controller 응답용 DTO
- 특징: record → 불변, getter 자동 생성, 변환 전용
1-2. DownloadInfo.java
public record DownloadInfo(
String originalFilename, // 원본 파일명
String contentType, // MIME 타입
Path filePath // 실제 서버 경로
) {}
- 역할: 다운로드용 DTO (Controller → ResponseEntity)
- 특징: 파일 경로 포함, 비즈니스 로직 없음
1-3. LoginRequest.java (Auth 관련)
public record LoginRequest(
@NotBlank @Email String email,
@NotBlank @Size(min = 8) String password
) {}
- 역할: 클라이언트 로그인 요청 입력 DTO
- 검증: @NotBlank, @Email, @Size
- 글로벌 핸들러 연계: MethodArgumentNotValidException 처리 가능
2. Entity
2-1. AttachmentEntity.java
@Entity
@Table(name = "attachments")
@Getter @Setter @NoArgsConstructor
public class AttachmentEntity {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "task_id", nullable = false)
private Long taskId;
@Column(name = "uploader_id", nullable = false)
private Long uploaderId;
@Column(name = "original_filename", nullable = false, length = 255)
private String originalFilename;
@Column(name = "stored_filename", nullable = false, length = 255)
private String storedFilename;
@Column(name = "content_type", length = 100)
private String contentType;
@Column(name = "size_bytes", nullable = false)
private Long sizeBytes;
@Column(name = "storage_path", nullable = false, length = 500)
private String storagePath;
@Column(name = "is_deleted", nullable = false)
private boolean isDeleted = false;
@Column(name = "deleted_at")
private LocalDateTime deletedAt;
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt = LocalDateTime.now();
}