package com.ssj.dao.weixin.library.dao;

import com.ssj.bean.weixin.libmy.domain.LibBookApply;
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;

@Repository
public interface IlibBookApplyDao extends JpaRepository<LibBookApply,String> {
    @Query(nativeQuery = true, value = "insert into tb_lib_book_locking(id,book_detail_id,book_info_id,isbn13,create_time,type,in_lib_id,stat,out_lib_id,update_time)\n" +
            "SELECT UUID(),t11.id,t.id,t.isbn13,NOW(),2,?3,2,'fa14e041-3823-4dac-b061-1e250e5a7d49',NOW()\n" +
            "from tb_lib_book_info t\n" +
            "left join tb_lib_book_detail t11 on t.id = t11.info_id\n" +
            "where t11.lib_id='fa14e041-3823-4dac-b061-1e250e5a7d49' and ?1  limit ?2")
    @Modifying
    void insertData(String toString, Integer bookSize,String libId);

    @Query(nativeQuery = true, value = "update tb_lib_book_apply set state=?3,audit_msg=?4 where lib_id=?1 and batch_id=?2 ")
    @Modifying
    void updateAudit(String libId, String batchId, int state, String msg);
}
