package com.jianshui.income.mapper;

import com.jianshui.income.domain.entity.InvoiceCheckUsedCar;
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 InvoiceCheckUsedCarMapper {


    @Insert({"replace into invoice_check_used_car " +
            " (invoice_check_id,cpzh,djzh,cjhj,zrdcgsmc,mfdwgr,mfdwdmsfzh,mfdwgrdz,mfdh,smfdwgr,smfdwdmsfzh,smfdwgrzz,smfdh,jypmdw,jypmdwdz,jypmdwzsbh,khyhjzh,jypmdwdh,escsc,escscsbh,escscdz,escsckhyhzh,escscdh,clsbh,cllx,cpxh) " +
            " values (#{invoice_check_id},#{cpzh},#{djzh},#{cjhj},#{zrdcgsmc},#{mfdwgr},#{mfdwdmsfzh},#{mfdwgrdz},#{mfdh},#{smfdwgr},#{smfdwdmsfzh},#{smfdwgrzz},#{smfdh},#{jypmdw},#{jypmdwdz},#{jypmdwzsbh},#{khyhjzh},#{jypmdwdh},#{escsc},#{escscsbh},#{escscdz},#{escsckhyhzh},#{escscdh},#{clsbh},#{cllx},#{cpxh}) "
    })
    public int insertData(InvoiceCheckUsedCar invoiceCheckUsedCar);

    /**
     * 批量插入
     *
     * @param invoiceCheckUsedCars
     * @return
     */
    @Insert(
            "<script> replace into invoice_check_used_car (invoice_check_id,cpzh,djzh,cjhj,zrdcgsmc,mfdwgr,mfdwdmsfzh,mfdwgrdz,mfdh,smfdwgr,smfdwdmsfzh,smfdwgrzz,smfdh,jypmdw,jypmdwdz,jypmdwzsbh,khyhjzh,jypmdwdh,escsc,escscsbh,escscdz,escsckhyhzh,escscdh,clsbh,cllx,cpxh) "
                    + " VALUES "
                    + "<foreach collection='list' item='record' separator=',' > "
                    + "(#{record.invoice_check_id},#{record.cpzh},#{record.djzh},#{record.cjhj},#{record.zrdcgsmc},#{record.mfdwgr},#{record.mfdwdmsfzh},#{record.mfdwgrdz},#{record.mfdh},#{record.smfdwgr},#{record.smfdwdmsfzh},#{record.smfdwgrzz},#{record.smfdh},#{record.jypmdw},#{record.jypmdwdz},#{record.jypmdwzsbh},#{record.khyhjzh},#{record.jypmdwdh},#{record.escsc},#{record.escscsbh},#{record.escscdz},#{record.escsckhyhzh},#{record.escscdh},#{record.clsbh},#{record.cllx},#{record.cpxh})"
                    + "</foreach>"
                    + "</script>"
    )
    public int replaceBatch(List<InvoiceCheckUsedCar> invoiceCheckUsedCars);

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

    public InvoiceCheckUsedCar selectInvoiceCheckUsedCarById(Long invoice_check_id);
}
