<?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.hw.mes.mapper.MesBasePalletInfoMapper">

    <resultMap type="MesBasePalletInfo" id="MesBasePalletInfoResult">
        <result property="palletInfoId" column="pallet_info_id"/>
        <result property="palletInfoCode" column="pallet_info_code"/>
        <result property="remark" column="remark"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectMesBasePalletInfoVo">
        select pallet_info_id, pallet_info_code, remark, create_by, create_time, update_by, update_time
        from mes_base_pallet_info
    </sql>

    <select id="selectMesBasePalletInfoList" parameterType="MesBasePalletInfo" resultMap="MesBasePalletInfoResult">
        <include refid="selectMesBasePalletInfoVo"/>
        <where>
            <if test="palletInfoCode != null  and palletInfoCode != ''">and pallet_info_code = #{palletInfoCode}</if>
        </where>
    </select>

    <select id="selectMesBasePalletInfoByPalletInfoId" parameterType="Long" resultMap="MesBasePalletInfoResult">
        <include refid="selectMesBasePalletInfoVo"/>
        where pallet_info_id = #{palletInfoId}
    </select>

    <insert id="insertMesBasePalletInfo" parameterType="MesBasePalletInfo" useGeneratedKeys="true"
            keyProperty="palletInfoId">
        insert into mes_base_pallet_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="palletInfoCode != null and palletInfoCode != ''">pallet_info_code,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="palletInfoCode != null and palletInfoCode != ''">#{palletInfoCode},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateMesBasePalletInfo" parameterType="MesBasePalletInfo">
        update mes_base_pallet_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="palletInfoCode != null and palletInfoCode != ''">pallet_info_code = #{palletInfoCode},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where pallet_info_id = #{palletInfoId}
    </update>

    <delete id="deleteMesBasePalletInfoByPalletInfoId" parameterType="Long">
        delete
        from mes_base_pallet_info
        where pallet_info_id = #{palletInfoId}
    </delete>

    <delete id="deleteMesBasePalletInfoByPalletInfoIds" parameterType="String">
        delete from mes_base_pallet_info where pallet_info_id in
        <foreach item="palletInfoId" collection="array" open="(" separator="," close=")">
            #{palletInfoId}
        </foreach>
    </delete>
</mapper>