<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.nanjing.mapper.TBdProductinfoMapper">

    <resultMap type="TBdProductinfo" id="TBdProductinfoResult">
        <result property="ID"    column="ID"    />
        <result property="productID"    column="ProductID"    />
        <result property="productName"    column="ProductName"    />
        <result property="productCode"    column="ProductCode"    />
        <result property="productType"    column="ProductType"    />
        <result property="userID"    column="UserID"    />
        <result property="updateTime"    column="UpdateTime"    />
        <result property="toolCarNo"    column="ToolCarNo"    />
        <result property="supplier"    column="Supplier"    />
        <result property="partNum"    column="partNum"    />
        <result property="softVersion"    column="SoftVersion"    />
        <result property="yieldly"    column="Yieldly"    />
        <result property="returnCount"    column="ReturnCount"    />
        <result property="machine"    column="Machine"    />
        <result property="ahopID"    column="ShopID"    />
        <result property="turnTo"    column="TurnTo"    />
        <result property="oil"    column="Oil"    />
        <result property="freezing"    column="Freezing"    />
        <result property="apeed"    column="Speed"    />
        <result property="volatage"    column="volatage"    />
        <result property="name"    column="Name"    />
        <result property="template"    column="Template"    />
        <result property="printType"    column="PrintType"    />
    </resultMap>

    <sql id="selectTBdProductinfoVo">
        select ID, ProductID, ProductName, ProductCode, ProductType, UserID, UpdateTime, ToolCarNo, Supplier, partNum, SoftVersion, Yieldly, ReturnCount, Machine, ShopID, TurnTo, Oil, Freezing, Speed, volatage, Name, Template, PrintType from T_BD_ProductInfo
    </sql>

    <select id="selectTBdProductinfo" resultMap="TBdProductinfoResult">
        select top 1 ID, ProductID, ProductName, ProductCode, ProductType, UserID, UpdateTime, ToolCarNo, Supplier, partNum, SoftVersion, Yieldly, ReturnCount, Machine, ShopID, TurnTo, Oil, Freezing, Speed, volatage, Name, Template, PrintType from T_BD_ProductInfo
        order by ProductID desc
    </select>
    <select id="selectTBdProductinfoList" parameterType="TBdProductinfo" resultMap="TBdProductinfoResult">
        <include refid="selectTBdProductinfoVo"/>
        <where>
            <if test="productName != null  and productName != ''"> and ProductName like ('%' + #{productName} + '%')</if>
            <if test="productType != null  and productType != ''"> and ProductType = #{productType}</if>
            <if test="toolCarNo != null  and toolCarNo != ''"> and ToolCarNo = #{toolCarNo}</if>
            <if test="machine != null  and machine != ''"> and Machine = #{machine}</if>
            <if test="template != null  and template != ''"> and Template = #{template}</if>
            <if test="printType != null  and printType != ''"> and PrintType = #{printType}</if>
        </where>
    </select>

    <select id="selectTBdProductinfoById" parameterType="Long" resultMap="TBdProductinfoResult">
        <include refid="selectTBdProductinfoVo"/>
        where ID = #{ID}
    </select>

    <insert id="insertTBdProductinfo" parameterType="TBdProductinfo">
        insert into T_BD_ProductInfo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ID != null">ID,</if>
            <if test="productID != null">ProductID,</if>
            <if test="productName != null">ProductName,</if>
            <if test="productCode != null">ProductCode,</if>
            <if test="productType != null">ProductType,</if>
            <if test="userID != null">UserID,</if>
            <if test="updateTime != null">UpdateTime,</if>
            <if test="toolCarNo != null">ToolCarNo,</if>
            <if test="supplier != null">Supplier,</if>
            <if test="partNum != null">partNum,</if>
            <if test="softVersion != null">SoftVersion,</if>
            <if test="yieldly != null">Yieldly,</if>
            <if test="returnCount != null">ReturnCount,</if>
            <if test="machine != null">Machine,</if>
            <if test="ahopID != null">ShopID,</if>
            <if test="turnTo != null">TurnTo,</if>
            <if test="oil != null">Oil,</if>
            <if test="freezing != null">Freezing,</if>
            <if test="apeed != null">Speed,</if>
            <if test="volatage != null">volatage,</if>
            <if test="name != null">Name,</if>
            <if test="template != null">Template,</if>
            <if test="printType != null">PrintType,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ID != null">#{ID},</if>
            <if test="productID != null">#{productID},</if>
            <if test="productName != null">#{productName},</if>
            <if test="productCode != null">#{productCode},</if>
            <if test="productType != null">#{productType},</if>
            <if test="userID != null">#{userID},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="toolCarNo != null">#{toolCarNo},</if>
            <if test="supplier != null">#{supplier},</if>
            <if test="partNum != null">#{partNum},</if>
            <if test="softVersion != null">#{softVersion},</if>
            <if test="yieldly != null">#{yieldly},</if>
            <if test="returnCount != null">#{returnCount},</if>
            <if test="machine != null">#{machine},</if>
            <if test="ahopID != null">#{ahopID},</if>
            <if test="turnTo != null">#{turnTo},</if>
            <if test="oil != null">#{oil},</if>
            <if test="freezing != null">#{freezing},</if>
            <if test="apeed != null">#{apeed},</if>
            <if test="volatage != null">#{volatage},</if>
            <if test="name != null">#{name},</if>
            <if test="template != null">#{template},</if>
            <if test="printType != null">#{printType},</if>
         </trim>
    </insert>

    <update id="updateTBdProductinfo" parameterType="TBdProductinfo">
        update T_BD_ProductInfo
        <trim prefix="SET" suffixOverrides=",">
            <if test="productID != null">ProductID = #{productID},</if>
            <if test="productName != null">ProductName = #{productName},</if>
            <if test="productCode != null">ProductCode = #{productCode},</if>
            <if test="productType != null">ProductType = #{productType},</if>
            <if test="userID != null">UserID = #{userID},</if>
            <if test="updateTime != null">UpdateTime = #{updateTime},</if>
            <if test="toolCarNo != null">ToolCarNo = #{toolCarNo},</if>
            <if test="supplier != null">Supplier = #{supplier},</if>
            <if test="partNum != null">partNum = #{partNum},</if>
            <if test="softVersion != null">SoftVersion = #{softVersion},</if>
            <if test="yieldly != null">Yieldly = #{yieldly},</if>
            <if test="returnCount != null">ReturnCount = #{returnCount},</if>
            <if test="machine != null">Machine = #{machine},</if>
            <if test="ahopID != null">ShopID = #{ahopID},</if>
            <if test="turnTo != null">TurnTo = #{turnTo},</if>
            <if test="oil != null">Oil = #{oil},</if>
            <if test="freezing != null">Freezing = #{freezing},</if>
            <if test="apeed != null">Speed = #{apeed},</if>
            <if test="volatage != null">volatage = #{volatage},</if>
            <if test="name != null">Name = #{name},</if>
            <if test="template != null">Template = #{template},</if>
            <if test="printType != null">PrintType = #{printType},</if>
        </trim>
        where ID = #{ID}
    </update>

    <delete id="deleteTBdProductinfoById" parameterType="Long">
        delete from T_BD_ProductInfo where ID = #{ID}
    </delete>

    <delete id="deleteTBdProductinfoByIds" parameterType="String">
        delete from T_BD_ProductInfo where ID in
        <foreach item="ID" collection="array" open="(" separator="," close=")">
            #{ID}
        </foreach>
    </delete>

</mapper>
