<?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.yunfeiyun.agmp.fms.mapper.WmsWarehouseMapper">

    <resultMap type="WmsWarehouse" id="WmsWarehouseResult">
        <result property="warehouseId"    column="warehouseId"    />
        <result property="warehouseName"    column="warehouseName"    />
        <result property="warehouseType"    column="warehouseType"    />
        <result property="warehouseUsestatus"    column="warehouseUsestatus"    />
        <result property="warehouseManager"    column="warehouseManager"    />
        <result property="warehouseManagername"    column="warehouseManagername"    />
        <result property="warehouseCreator"    column="warehouseCreator"    />
        <result property="warehouseCreatorname"    column="warehouseCreatorname"    />
        <result property="warehouseCreateddate"    column="warehouseCreateddate"    />
    </resultMap>

    <sql id="selectWmsWarehouseVo">
        select warehouseId, warehouseName, warehouseType, warehouseUsestatus, warehouseManager, warehouseManagername, warehouseCreator, warehouseCreatorname, warehouseCreateddate from WmsWarehouse
    </sql>

    <select id="selectWmsWarehouseList" parameterType="WmsWarehouse" resultMap="WmsWarehouseResult">
        select warehouseId, warehouseName, warehouseType, warehouseUsestatus, warehouseManager, warehouseManagername, warehouseCreator, warehouseCreatorname, warehouseCreateddate from WmsWarehouse
        <where>
            <if test="warehouseName != null  and warehouseName != ''"> and warehouseName like concat('%', #{warehouseName}, '%')</if>
            <if test="warehouseType != null  and warehouseType != '' and warehouseType != '-1'"> and warehouseType = #{warehouseType}</if>
            <if test="warehouseUsestatus != null  and warehouseUsestatus != ''"> and warehouseUsestatus = #{warehouseUsestatus}</if>
            <if test="warehouseManager != null  and warehouseManager != ''"> and warehouseManager = #{warehouseManager}</if>
            <if test="warehouseManagername != null  and warehouseManagername != ''"> and warehouseManagername like concat('%', #{warehouseManagername}, '%')</if>
            <if test="warehouseCreator != null  and warehouseCreator != ''"> and warehouseCreator = #{warehouseCreator}</if>
            <if test="warehouseCreatorname != null  and warehouseCreatorname != ''"> and warehouseCreatorname like concat('%', #{warehouseCreatorname}, '%')</if>
            <if test="warehouseCreateddate != null  and warehouseCreateddate != ''"> and warehouseCreateddate = #{warehouseCreateddate}</if>
        </where>
    </select>

    <select id="selectWmsWarehouseByWarehouseId" parameterType="String" resultMap="WmsWarehouseResult">
        <include refid="selectWmsWarehouseVo"/>
        where warehouseId = #{warehouseId}
    </select>

    <insert id="insertWmsWarehouse" parameterType="WmsWarehouse">
        insert into WmsWarehouse
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="warehouseId != null">warehouseId,</if>
            <if test="warehouseName != null">warehouseName,</if>
            <if test="warehouseType != null">warehouseType,</if>
            <if test="warehouseUsestatus != null">warehouseUsestatus,</if>
            <if test="warehouseManager != null">warehouseManager,</if>
            <if test="warehouseManagername != null">warehouseManagername,</if>
            <if test="warehouseCreator != null">warehouseCreator,</if>
            <if test="warehouseCreatorname != null">warehouseCreatorname,</if>
            <if test="warehouseCreateddate != null">warehouseCreateddate,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="warehouseId != null">#{warehouseId},</if>
            <if test="warehouseName != null">#{warehouseName},</if>
            <if test="warehouseType != null">#{warehouseType},</if>
            <if test="warehouseUsestatus != null">#{warehouseUsestatus},</if>
            <if test="warehouseManager != null">#{warehouseManager},</if>
            <if test="warehouseManagername != null">#{warehouseManagername},</if>
            <if test="warehouseCreator != null">#{warehouseCreator},</if>
            <if test="warehouseCreatorname != null">#{warehouseCreatorname},</if>
            <if test="warehouseCreateddate != null">#{warehouseCreateddate},</if>
        </trim>
    </insert>

    <update id="updateWmsWarehouse" parameterType="WmsWarehouse">
        update WmsWarehouse
        <trim prefix="SET" suffixOverrides=",">
            <if test="warehouseName != null">warehouseName = #{warehouseName},</if>
            <if test="warehouseType != null">warehouseType = #{warehouseType},</if>
            <if test="warehouseUsestatus != null">warehouseUsestatus = #{warehouseUsestatus},</if>
            <if test="warehouseManager != null">warehouseManager = #{warehouseManager},</if>
            <if test="warehouseManagername != null">warehouseManagername = #{warehouseManagername},</if>
            <if test="warehouseCreator != null">warehouseCreator = #{warehouseCreator},</if>
            <if test="warehouseCreatorname != null">warehouseCreatorname = #{warehouseCreatorname},</if>
            <if test="warehouseCreateddate != null">warehouseCreateddate = #{warehouseCreateddate},</if>
        </trim>
        where warehouseId = #{warehouseId}
    </update>

    <delete id="deleteWmsWarehouseByWarehouseId" parameterType="String">
        delete from WmsWarehouse where warehouseId = #{warehouseId}
    </delete>

    <delete id="deleteWmsWarehouseByWarehouseIds" parameterType="String">
        delete from WmsWarehouse where warehouseId in
        <foreach item="warehouseId" collection="array" open="(" separator="," close=")">
            #{warehouseId}
        </foreach>
    </delete>
</mapper>