<?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.wms.mapper.WmsBaseContainerMapper">
    
    <resultMap type="WmsBaseContainer" id="WmsBaseContainerResult">
        <result property="baseContainerId"    column="base_container_id"    />
        <result property="baseContainerCode"    column="base_container_code"    />
        <result property="warehouseId"    column="warehouse_id"    />
        <result property="locationCode"    column="location_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="selectWmsBaseContainerVo">
        select base_container_id, base_container_code, warehouse_id, location_code, remark, create_by, create_time, update_by, update_time from wms_base_container
    </sql>

    <select id="selectWmsBaseContainerList" parameterType="WmsBaseContainer" resultMap="WmsBaseContainerResult">
        <include refid="selectWmsBaseContainerVo"/>
        <where>  
            <if test="baseContainerCode != null  and baseContainerCode != ''"> and base_container_code = #{baseContainerCode}</if>
            <if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
            <if test="locationCode != null  and locationCode != ''"> and location_code = #{locationCode}</if>
        </where>
    </select>
    
    <select id="selectWmsBaseContainerByBaseContainerId" parameterType="Long" resultMap="WmsBaseContainerResult">
        <include refid="selectWmsBaseContainerVo"/>
        where base_container_id = #{baseContainerId}
    </select>
        
    <insert id="insertWmsBaseContainer" parameterType="WmsBaseContainer" useGeneratedKeys="true" keyProperty="baseContainerId">
        insert into wms_base_container
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="baseContainerCode != null and baseContainerCode != ''">base_container_code,</if>
            <if test="warehouseId != null">warehouse_id,</if>
            <if test="locationCode != null">location_code,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">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="baseContainerCode != null and baseContainerCode != ''">#{baseContainerCode},</if>
            <if test="warehouseId != null">#{warehouseId},</if>
            <if test="locationCode != null">#{locationCode},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateWmsBaseContainer" parameterType="WmsBaseContainer">
        update wms_base_container
        <trim prefix="SET" suffixOverrides=",">
            <if test="baseContainerCode != null and baseContainerCode != ''">base_container_code = #{baseContainerCode},</if>
            <if test="warehouseId != null">warehouse_id = #{warehouseId},</if>
            <if test="locationCode != null">location_code = #{locationCode},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">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 base_container_id = #{baseContainerId}
    </update>

    <delete id="deleteWmsBaseContainerByBaseContainerId" parameterType="Long">
        delete from wms_base_container where base_container_id = #{baseContainerId}
    </delete>

    <delete id="deleteWmsBaseContainerByBaseContainerIds" parameterType="String">
        delete from wms_base_container where base_container_id in 
        <foreach item="baseContainerId" collection="array" open="(" separator="," close=")">
            #{baseContainerId}
        </foreach>
    </delete>
</mapper>