package com.hfkj.dao;

import com.hfkj.entity.BsGasOilGunNo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * mapper扩展类
 */
public interface BsGasOilGunNoMapperExt {

    @Insert({
            "<script>" +
            "insert into bs_gas_oil_gun_no (gas_oil_price_id, mer_id, ",
            "mer_no, oil_type, ",
            "oil_type_name, oil_no, ",
            "oil_no_name, gun_no, ",
            "`status`, create_time, ",
            "ext_1, ext_2, ext_3)",
            "values " +
            "<foreach collection='list' item='item' separator=','>",
            " (#{item.gasOilPriceId}, #{item.merId}, ",
            " #{item.merNo}, #{item.oilType}, ",
            " #{item.oilTypeName}, #{item.oilNo}, ",
            " #{item.oilNoName}, #{item.gunNo}, ",
            " #{item.status}, #{item.createTime}, ",
            " #{item.ext1}, #{item.ext2}, #{item.ext3})" +
            "</foreach>" +
            "</script>",
    })
    void batchInsert(@Param(value = "list") List<BsGasOilGunNo> list);

    @Update({
            "<script>" +
                "<foreach collection='list' item='item' separator=';'>",
                " update bs_gas_oil_gun_no",
                " set" +
                " gas_oil_price_id = #{item.gasOilPriceId},",
                " mer_id = #{item.merId},",
                " mer_no = #{item.merNo},",
                " oil_type = #{item.oilType},",
                " oil_type_name = #{item.oilTypeName},",
                " oil_no = #{item.oilNo},",
                " oil_no_name = #{item.oilNoName},",
                " gun_no = #{item.gunNo},",
                " `status` = #{item.status},",
                " create_time = #{item.createTime},",
                " ext_1 = #{item.ext1},",
                " ext_2 = #{item.ext2},",
                " ext_3 = #{item.ext3}",
                " where id = #{item.id}",
                "</foreach>" +
            "</script>",
    })
    void batchUpdate(@Param(value = "list") List<BsGasOilGunNo> list);
}
