<?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="cn.gov.customs.wxjy.base.dao.PackCatalogMapper">

    <resultMap type="PackCatalog" id="PackCatalogResult">
        <result property="id" column="ID"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDept" column="CREATE_DEPT"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="updateUser" column="UPDATE_USER"/>
        <result property="updateTime" column="UPDATE_TIME"/>
        <result property="isDeleted" column="IS_DELETED"/>
        <result property="status" column="STATUS"/>
        <result property="maxType" column="MAX_TYPE"/>
        <result property="minTypeCode" column="MIN_TYPE_CODE"/>
        <result property="minTypeName" column="MIN_TYPE_NAME"/>
        <result property="requireInfo" column="REQUIRE_INFO"/>
        <result property="maxL" column="MAX_L"/>
        <result property="maxKg" column="MAX_KG"/>
        <result property="packStatus" column="PACK_STATUS"/>
    </resultMap>

    <sql id="baseVo">
        select ID, CREATE_USER, CREATE_DEPT, CREATE_TIME, UPDATE_USER, UPDATE_TIME, IS_DELETED, STATUS, MAX_TYPE, MIN_TYPE_CODE, MIN_TYPE_NAME, REQUIRE_INFO, MAX_L, MAX_KG, PACK_STATUS
        from WXJY_PACK_CATALOG
    </sql>

    <select id="selectList" parameterType="PackCatalogQuery" resultMap="PackCatalogResult">
        <include refid="baseVo"/>
        <where>
            and IS_DELETED = 0
        <if test="id != null  and id != ''">
            and ID = #{id}
        </if>
        <if test="createUser != null  and createUser != ''">
            and CREATE_USER = #{createUser}
        </if>
        <if test="createDept != null  and createDept != ''">
            and CREATE_DEPT = #{createDept}
        </if>
        <if test="createTime != null  and createTime != ''">
            and CREATE_TIME = #{createTime}
        </if>
        <if test="updateUser != null  and updateUser != ''">
            and UPDATE_USER = #{updateUser}
        </if>
        <if test="updateTime != null ">
            and UPDATE_TIME &gt;= #{updateTime}
        </if>
        <if test="isDeleted != null  and isDeleted != ''">
            and IS_DELETED = #{isDeleted}
        </if>
        <if test="status != null  and status != ''">
            and STATUS = #{status}
        </if>
        <if test="maxType != null  and maxType != ''">
            and MAX_TYPE like concat('%', #{maxType}, '%')
        </if>
        <if test="minTypeCode != null  and minTypeCode != ''">
            and MIN_TYPE_CODE like concat('%', #{minTypeCode}, '%')
        </if>
        <if test="minTypeName != null  and minTypeName != ''">
            and MIN_TYPE_NAME like concat('%', #{minTypeName}, '%')
        </if>
        <if test="requireInfo != null  and requireInfo != ''">
            and REQUIRE_INFO = #{requireInfo}
        </if>
        <if test="maxL != null  and maxL != ''">
            and MAX_L = #{maxL}
        </if>
        <if test="maxKg != null  and maxKg != ''">
            and MAX_KG = #{maxKg}
        </if>
        <if test="packStatus != null  and packStatus != ''">
            and PACK_STATUS = #{packStatus}
        </if>
        </where>
        order by update_time desc
    </select>

    <select id="selectByID" parameterType="String"
        resultMap="PackCatalogResult">
        <include refid="baseVo"/>
        where ID = #{id}
    </select>

    <insert id="insert" parameterType="PackCatalog">
        insert into WXJY_PACK_CATALOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">ID,
            </if>
            <if test="createUser != null">CREATE_USER,
            </if>
            <if test="createDept != null">CREATE_DEPT,
            </if>
            <if test="createTime != null">CREATE_TIME,
            </if>
            <if test="updateUser != null">UPDATE_USER,
            </if>
            <if test="updateTime != null">UPDATE_TIME,
            </if>
            <if test="isDeleted != null">IS_DELETED,
            </if>
            <if test="status != null">STATUS,
            </if>
            <if test="maxType != null">MAX_TYPE,
            </if>
            <if test="minTypeCode != null">MIN_TYPE_CODE,
            </if>
            <if test="minTypeName != null">MIN_TYPE_NAME,
            </if>
            <if test="requireInfo != null">REQUIRE_INFO,
            </if>
            <if test="maxL != null">MAX_L,
            </if>
            <if test="maxKg != null">MAX_KG,
            </if>
            <if test="packStatus != null">PACK_STATUS,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},
            </if>
            <if test="createUser != null">#{createUser},
            </if>
            <if test="createDept != null">#{createDept},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateUser != null">#{updateUser},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="isDeleted != null">#{isDeleted},
            </if>
            <if test="status != null">#{status},
            </if>
            <if test="maxType != null">#{maxType},
            </if>
            <if test="minTypeCode != null">#{minTypeCode},
            </if>
            <if test="minTypeName != null">#{minTypeName},
            </if>
            <if test="requireInfo != null">#{requireInfo},
            </if>
            <if test="maxL != null">#{maxL},
            </if>
            <if test="maxKg != null">#{maxKg},
            </if>
            <if test="packStatus != null">#{packStatus},
            </if>
        </trim>
    </insert>

    <update id="update" parameterType="PackCatalog">
        update WXJY_PACK_CATALOG
        <trim prefix="SET" suffixOverrides=",">
            <if test="createUser != null">CREATE_USER =
                #{createUser},
            </if>
            <if test="createDept != null">CREATE_DEPT =
                #{createDept},
            </if>
            <if test="createTime != null">CREATE_TIME =
                #{createTime},
            </if>
            <if test="updateUser != null">UPDATE_USER =
                #{updateUser},
            </if>
            <if test="updateTime != null">UPDATE_TIME =
                #{updateTime},
            </if>
            <if test="isDeleted != null">IS_DELETED =
                #{isDeleted},
            </if>
            <if test="status != null">STATUS =
                #{status},
            </if>
            <if test="maxType != null">MAX_TYPE =
                #{maxType},
            </if>
            <if test="minTypeCode != null">MIN_TYPE_CODE =
                #{minTypeCode},
            </if>
            <if test="minTypeName != null">MIN_TYPE_NAME =
                #{minTypeName},
            </if>
            <if test="requireInfo != null">REQUIRE_INFO =
                #{requireInfo},
            </if>
            <if test="maxL != null">MAX_L =
                #{maxL},
            </if>
            <if test="maxKg != null">MAX_KG =
                #{maxKg},
            </if>
            <if test="packStatus != null">PACK_STATUS =
                #{packStatus},
            </if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteByID" parameterType="String">
        delete
        from WXJY_PACK_CATALOG where ID = #{id}
    </delete>

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

    <delete id="logicDelete" parameterType="String">
        update  WXJY_PACK_CATALOG set is_del = 1  where ID = #{id}
    </delete>
</mapper>