package com.ann.demo.repository;

import com.ann.demo.entity.interfaceEntity.ExamApply;
import org.springframework.data.jpa.repository.JpaRepository;
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;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/8/22 16:22
 */
@Repository
public interface ExamApplyRepository extends JpaRepository<ExamApply, String> {

    @Transactional
    @Modifying
    @Query("update ExamApply o set o.isValid = 1 where o.applyId = ?1 and o.isValid = 0 ")
    public Integer updateExamApplyIsValidById(String applyId);

    @Query("select count(o) from ExamApply o  where o.applyId = ?1 and o.isValid = 0")
    public Integer countExamApply(String applyId);

    public ExamApply findByApplyIdAndIsValidAndIsOpenHisAndIsOpenOther(String applyId,Integer isValid,String isOpenHis,String isOpenOther);

}
