<?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.GoodsCatalogMapper">

    <resultMap type="GoodsCatalog" id="GoodsCatalogResult">
        <result property="id" column="ID"/>
        <result property="unCode" column="UN_CODE"/>
        <result property="chName" column="CH_NAME"/>
        <result property="dangerSort" column="DANGER_SORT"/>
        <result property="viceDanger" column="VICE_DANGER"/>
        <result property="packType" column="PACK_TYPE"/>
        <result property="specialProvision" column="SPECIAL_PROVISION"/>
        <result property="limited" column="LIMITED"/>
        <result property="exemptAmount" column="EXEMPT_AMOUNT"/>
        <result property="packGuideline" column="PACK_GUIDELINE"/>
        <result property="packProvision" column="PACK_PROVISION"/>
        <result property="containerGuideline" column="CONTAINER_GUIDELINE"/>
        <result property="containerProvision" column="CONTAINER_PROVISION"/>
        <result property="tankGuideline" column="TANK_GUIDELINE"/>
        <result property="tankProvision" column="TANK_PROVISION"/>
        <result property="ems" column="EMS"/>
        <result property="stowageOperate" column="STOWAGE_OPERATE"/>
        <result property="isolation" column="ISOLATION"/>
        <result property="feature" column="FEATURE"/>
        <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="signs" column="SIGNS"/>
    </resultMap>

    <sql id="baseVo">
        select ID, UN_CODE, CH_NAME, DANGER_SORT, VICE_DANGER, PACK_TYPE, SPECIAL_PROVISION, LIMITED, EXEMPT_AMOUNT, PACK_GUIDELINE, PACK_PROVISION, CONTAINER_GUIDELINE, CONTAINER_PROVISION, TANK_GUIDELINE, TANK_PROVISION, EMS, STOWAGE_OPERATE, ISOLATION, FEATURE, CREATE_USER, CREATE_DEPT, CREATE_TIME, UPDATE_USER, UPDATE_TIME, IS_DELETED, STATUS, SIGNS
        from WXJY_GOODS_CATALOG
    </sql>

    <select id="selectList" parameterType="GoodsCatalogQuery" resultMap="GoodsCatalogResult">
        <include refid="baseVo"/>
        <where>
        and IS_DELETED = 0
        <if test="unCode != null  and unCode != ''">
            and UN_CODE like concat('%', #{unCode}, '%')
        </if>
        <if test="chName != null  and chName != ''">
            and CH_NAME like concat('%', #{chName}, '%')
        </if>
        <if test="dangerSort != null  and dangerSort != ''">
            and DANGER_SORT like concat('%', #{dangerSort}, '%')
        </if>
        <if test="viceDanger != null  and viceDanger != ''">
            and VICE_DANGER like concat('%', #{viceDanger}, '%')
        </if>
        <if test="packType != null  and packType != ''">
            and PACK_TYPE = #{packType}
        </if>
        <if test="specialProvision != null  and specialProvision != ''">
            and SPECIAL_PROVISION = #{specialProvision}
        </if>
        <if test="limited != null  and limited != ''">
            and LIMITED = #{limited}
        </if>
        <if test="exemptAmount != null  and exemptAmount != ''">
            and EXEMPT_AMOUNT = #{exemptAmount}
        </if>
        <if test="packGuideline != null  and packGuideline != ''">
            and PACK_GUIDELINE = #{packGuideline}
        </if>
        <if test="packProvision != null  and packProvision != ''">
            and PACK_PROVISION = #{packProvision}
        </if>
        <if test="containerGuideline != null  and containerGuideline != ''">
            and CONTAINER_GUIDELINE = #{containerGuideline}
        </if>
        <if test="containerProvision != null  and containerProvision != ''">
            and CONTAINER_PROVISION = #{containerProvision}
        </if>
        <if test="tankGuideline != null  and tankGuideline != ''">
            and TANK_GUIDELINE = #{tankGuideline}
        </if>
        <if test="tankProvision != null  and tankProvision != ''">
            and TANK_PROVISION = #{tankProvision}
        </if>
        <if test="ems != null  and ems != ''">
            and EMS = #{ems}
        </if>
        <if test="stowageOperate != null  and stowageOperate != ''">
            and STOWAGE_OPERATE = #{stowageOperate}
        </if>
        <if test="isolation != null  and isolation != ''">
            and ISOLATION = #{isolation}
        </if>
        <if test="feature != null  and feature != ''">
            and FEATURE = #{feature}
        </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="signs != null  and signs != ''">
            and SIGNS = #{SIGNS}
        </if>
        </where>
        order by update_time desc
    </select>

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

    <insert id="insert" parameterType="GoodsCatalog">
        insert into WXJY_GOODS_CATALOG
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">ID,
            </if>
            <if test="unCode != null">UN_CODE,
            </if>
            <if test="chName != null">CH_NAME,
            </if>
            <if test="dangerSort != null">DANGER_SORT,
            </if>
            <if test="viceDanger != null">VICE_DANGER,
            </if>
            <if test="packType != null">PACK_TYPE,
            </if>
            <if test="specialProvision != null">SPECIAL_PROVISION,
            </if>
            <if test="limited != null">LIMITED,
            </if>
            <if test="exemptAmount != null">EXEMPT_AMOUNT,
            </if>
            <if test="packGuideline != null">PACK_GUIDELINE,
            </if>
            <if test="packProvision != null">PACK_PROVISION,
            </if>
            <if test="containerGuideline != null">CONTAINER_GUIDELINE,
            </if>
            <if test="containerProvision != null">CONTAINER_PROVISION,
            </if>
            <if test="tankGuideline != null">TANK_GUIDELINE,
            </if>
            <if test="tankProvision != null">TANK_PROVISION,
            </if>
            <if test="ems != null">EMS,
            </if>
            <if test="stowageOperate != null">STOWAGE_OPERATE,
            </if>
            <if test="isolation != null">`ISOLATION`,
            </if>
            <if test="feature != null">FEATURE,
            </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="signs != null">SIGNS,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{ID},
            </if>
            <if test="unCode != null">#{unCode},
            </if>
            <if test="chName != null">#{chName},
            </if>
            <if test="dangerSort != null">#{dangerSort},
            </if>
            <if test="viceDanger != null">#{viceDanger},
            </if>
            <if test="packType != null">#{packType},
            </if>
            <if test="specialProvision != null">#{specialProvision},
            </if>
            <if test="limited != null">#{limited},
            </if>
            <if test="exemptAmount != null">#{exemptAmount},
            </if>
            <if test="packGuideline != null">#{packGuideline},
            </if>
            <if test="packProvision != null">#{packProvision},
            </if>
            <if test="containerGuideline != null">#{containerGuideline},
            </if>
            <if test="containerProvision != null">#{containerProvision},
            </if>
            <if test="tankGuideline != null">#{tankGuideline},
            </if>
            <if test="tankProvision != null">#{tankProvision},
            </if>
            <if test="ems != null">#{ems},
            </if>
            <if test="stowageOperate != null">#{stowageOperate},
            </if>
            <if test="isolation != null">#{isolation},
            </if>
            <if test="feature != null">#{feature},
            </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="signs != null">#{signs},
            </if>
        </trim>
    </insert>

    <update id="update" parameterType="GoodsCatalog">
        update WXJY_GOODS_CATALOG
        <trim prefix="SET" suffixOverrides=",">
            <if test="unCode != null">UN_CODE =
                #{unCode},
            </if>
            <if test="chName != null">CH_NAME =
                #{chName},
            </if>
            <if test="dangerSort != null">DANGER_SORT =
                #{dangerSort},
            </if>
            <if test="viceDanger != null">VICE_DANGER =
                #{viceDanger},
            </if>
            <if test="packType != null">PACK_TYPE =
                #{packType},
            </if>
            <if test="specialProvision != null">SPECIAL_PROVISION =
                #{specialProvision},
            </if>
            <if test="limited != null">LIMITED =
                #{limited},
            </if>
            <if test="exemptAmount != null">EXEMPT_AMOUNT =
                #{exemptAmount},
            </if>
            <if test="packGuideline != null">PACK_GUIDELINE =
                #{packGuideline},
            </if>
            <if test="packProvision != null">PACK_PROVISION =
                #{packProvision},
            </if>
            <if test="containerGuideline != null">CONTAINER_GUIDELINE =
                #{containerGuideline},
            </if>
            <if test="containerProvision != null">CONTAINER_PROVISION =
                #{containerProvision},
            </if>
            <if test="tankGuideline != null">TANK_GUIDELINE =
                #{tankGuideline},
            </if>
            <if test="tankProvision != null">TANK_PROVISION =
                #{tankProvision},
            </if>
            <if test="ems != null">EMS =
                #{ems},
            </if>
            <if test="stowageOperate != null">STOWAGE_OPERATE =
                #{stowageOperate},
            </if>
            <if test="isolation != null">`ISOLATION` =
                #{isolation},
            </if>
            <if test="feature != null">FEATURE =
                #{feature},
            </if>
            <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="signs != null">SIGNS =
                #{signs},
            </if>
        </trim>
        where ID = #{ID}
    </update>

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

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

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