| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package com.loan.system.repository;
- import com.loan.system.domain.dto.DocumentDTO;
- import com.loan.system.domain.dto.query.DocumentQueryDTO;
- import com.loan.system.domain.entity.DictBusinessType;
- import com.loan.system.domain.entity.Document;
- import com.loan.system.domain.vo.DocumentVO;
- import org.springframework.data.domain.Page;
- import org.springframework.data.domain.Pageable;
- import org.springframework.data.jpa.repository.JpaRepository;
- import org.springframework.data.jpa.repository.Modifying;
- import org.springframework.data.jpa.repository.Query;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.List;
- /**
- * @author EdwinXu
- * @date 2020/9/2 - 15:35
- * @Description
- */
- public interface DocumentRepository extends JpaRepository<Document,Long> {
- List<Document> findByCaseId(Long caseId);
- @Query("select d from Document d where d.id = ?1 and d.isDelete =?2")
- Document findByDocumentIdAndIsDelete(Long signId, Boolean isDelete);
- @Transactional
- @Modifying
- @Query("UPDATE Document d SET " +
- "d.ownerId = CASE WHEN :#{#document.ownerId} IS NOT NULL THEN :#{#document.ownerId} ELSE d.ownerId END, " +
- "d.docType = CASE WHEN :#{#document.docType} IS NOT NULL THEN :#{#document.docType} ELSE d.docType END, " +
- "d.filePath = CASE WHEN :#{#document.filePath} IS NOT NULL THEN :#{#document.filePath} ELSE d.filePath END, " +
- "d.fileName = CASE WHEN :#{#document.fileName} IS NOT NULL THEN :#{#document.fileName} ELSE d.fileName END, " +
- "d.fileSize = CASE WHEN :#{#document.fileSize} IS NOT NULL THEN :#{#document.fileSize} ELSE d.fileSize END ," +
- "d.updateTime = CASE WHEN :#{#document.updateTime} IS NOT NULL THEN :#{#document.updateTime} ELSE d.updateTime END " +
- "WHERE d.caseId = :caseId AND d.dictType = :dictType")
- void updateByCaseIdAndDictType(Long caseId, String dictType, Document document);
- @Transactional
- @Modifying
- @Query("DELETE FROM Document d WHERE d.caseId = :caseId AND d.dictType = :fileType")
- void deleteFileByCaseIdAndDictType(Long caseId, String fileType);
- @Query("select d from Document d where d.dictType in ?1 and d.caseId = ?2 and d.isDelete = ?3")
- List<Document> findByFileTypesAndCaseIdAndIsDelete(List<String> fileTypes, Long caseId, boolean b);
- @Query("select d from Document d where d.isDelete = ?1")
- Page<Document> findAllAndIdDelete(boolean b , Pageable pageable );
- @Transactional
- @Modifying
- @Query("update Document d set d.isDelete = false WHERE d.id in ?1")
- void deleteByIds(List<Long> ids);
- @Query("SELECT lc FROM Document lc WHERE " +
- "(:#{#query.caseId} IS NULL OR lc.caseId = :#{#query.caseId}) AND " +
- "(:#{#query.docType} IS NULL OR lc.docType = :#{#query.docType}) AND " +
- "(:#{#query.originName} IS NULL OR lc.originName like %:#{#query.originName}%) AND " +
- "(:#{#query.dictType} IS NULL OR lc.dictType = :#{#query.dictType} AND " +
- "lc.isDelete = false)")
- Page<Document> findByQuery(DocumentQueryDTO query, Pageable pageable);
- }
|