package com.jianshui.income.mapper;

import com.jianshui.income.domain.entity.InvoiceCheckCar;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface InvoiceCheckCarMapper {


    /**
     * 插入数据
     *
     * @param invoiceCheckCar
     * @return
     */
    @Insert({"replace into invoice_check_car " +
            " (invoice_check_id,sfzh,cllx,cpxh,cd,hgzs,sjdh,fdjhm,clsbh,jszmsh,zgswjgdm,wspzhm,xcrs,zgswjgmc,dw,sl,khyh,khzh,smfdh) " +
            " values (#{invoice_check_id},#{sfzh},#{cllx},#{cpxh},#{cd},#{hgzs},#{sjdh},#{fdjhm},#{clsbh},#{jszmsh},#{zgswjgdm},#{wspzhm},#{xcrs},#{zgswjgmc},#{dw},#{sl},#{khyh},#{khzh},#{smfdh}) "
    })
    public int insertData(InvoiceCheckCar invoiceCheckCar);


    /**
     * 批量插入
     *
     * @param invoiceCheckCarList
     * @return
     */
    @Insert(
            "<script> replace into invoice_check_car (invoice_check_id,sfzh,cllx,cpxh,cd,hgzs,sjdh,fdjhm,clsbh,jszmsh,zgswjgdm,wspzhm,xcrs,zgswjgmc,dw,sl,khyh,khzh,smfdh) "
                    + " VALUES "
                    + "<foreach collection='list' item='record' separator=',' > "
                    + "(#{record.invoice_check_id},#{record.sfzh},#{record.cllx},#{record.cpxh},#{record.cd},#{record.hgzs},#{record.sjdh},#{record.fdjhm},#{record.clsbh},#{record.jszmsh},#{record.zgswjgdm},#{record.wspzhm},#{record.xcrs},#{record.zgswjgmc},#{record.dw},#{record.sl},#{record.khyh},#{record.khzh},#{record.smfdh})"
                    + "</foreach>"
                    + "</script>"
    )
    public int replaceBatch(List<InvoiceCheckCar> invoiceCheckCarList);

    @Select("select * from invoice_check_car where invoice_check_id = #{invoice_check_id} limit 1")
    public InvoiceCheckCar selectOne(@Param("invoice_check_id") int invoice_check_id);

    public InvoiceCheckCar selectInvoiceCheckCarById(Long invoice_check_id);
}
