package com.gkhy.labRiskManage.domain.attachment.repository.jpa; import com.gkhy.labRiskManage.domain.attachment.entity.AttachmentInfo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; import java.util.Optional; /** * @email 1603559716@qq.com * @author: zf * @date: 2023/5/6 * @time: 21:28 */ @Repository public interface AttachmentReposity extends JpaRepository, JpaSpecificationExecutor { @Query(value = "select a from AttachmentInfo a where a.fileKey = :fileKey and a.delFlag = 0") AttachmentInfo findByFileKey(String fileKey); @Query(value = "select a from AttachmentInfo a where a.id = :id and a.delFlag = 0") AttachmentInfo getById(Long id); @Transactional @Query(value = "update AttachmentInfo a set a.delFlag = 1 where a.id = :id") @Modifying Integer deleteAttachment(Long id); }