package com.loan.system.repository;

import com.loan.system.domain.entity.Contract;
import com.loan.system.domain.entity.ContractSeq;
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 ContractSeqRepository extends JpaRepository<ContractSeq,Long> {

    @Query("select c from ContractSeq c where c.seqData = ?1 AND c.businessAttr = ?2")
    ContractSeq findSeqBySeqDataAndBusinessAttr(String tody,String businessAttr);

    @Transactional
    @Modifying
    @Query("update ContractSeq c set c.nextSeq = ?2 where c.id = ?1")
    void updateSeqById(Long id, long l);
}