AttachmentRepository.java

역할


1. 주요 메서드

1-1. 업무별 활성 첨부파일 조회

List<AttachmentEntity> findByTaskIdAndIsDeletedFalseOrderByIdDesc(Long taskId);

1-2. 첨부파일 단건 조회 (다운로드/삭제)

java.util.Optional<AttachmentEntity> findByIdAndIsDeletedFalse(Long id);

1-3. Cleanup 대상 조회 (soft delete 후 일정 기간 지난 파일)

@Query("""
    select a
      from AttachmentEntity a
     where a.isDeleted = true
       and a.deletedAt is not null
       and a.deletedAt < :cutoff
     order by a.deletedAt asc
""")
List<AttachmentEntity> findCleanupTargets(@Param("cutoff") LocalDateTime cutoff);

1-4. 물리 삭제 (DB row 제거)