<?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.aucma.dms.mapper.DmsBaseShutTypeMapper">
    
    <resultMap type="DmsBaseShutType" id="DmsBaseShutTypeResult">
        <result property="shutTypeId"    column="shut_type_id"    />
        <result property="typeCode"    column="type_code"    />
        <result property="shutTypeName"    column="shut_type_name"    />
        <result property="isFlag"    column="is_flag"    />
        <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="selectDmsBaseShutTypeVo">
        select shut_type_id, type_code, shut_type_name, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_shut_type
    </sql>

    <select id="selectDmsBaseShutTypeList" parameterType="DmsBaseShutType" resultMap="DmsBaseShutTypeResult">
        <include refid="selectDmsBaseShutTypeVo"/>
        <where>  
            <if test="typeCode != null  and typeCode != ''"> and type_code = #{typeCode}</if>
            <if test="shutTypeName != null  and shutTypeName != ''"> and shut_type_name like concat('%', #{shutTypeName}, '%')</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsBaseShutTypeByShutTypeId" parameterType="Long" resultMap="DmsBaseShutTypeResult">
        <include refid="selectDmsBaseShutTypeVo"/>
        where shut_type_id = #{shutTypeId}
    </select>
        
    <insert id="insertDmsBaseShutType" parameterType="DmsBaseShutType">
        <selectKey keyProperty="shutTypeId" resultType="long" order="BEFORE">
            SELECT SEQ_DMS_SHUT_TYPE.NEXTVAL FROM DUAL
        </selectKey>
        insert into dms_base_shut_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="shutTypeId != null">shut_type_id,</if>
            <if test="typeCode != null">type_code,</if>
            <if test="shutTypeName != null and shutTypeName != ''">shut_type_name,</if>
            <if test="isFlag != null and isFlag != ''">is_flag,</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="shutTypeId != null">#{shutTypeId},</if>
            <if test="typeCode != null">#{typeCode},</if>
            <if test="shutTypeName != null and shutTypeName != ''">#{shutTypeName},</if>
            <if test="isFlag != null and isFlag != ''">#{isFlag},</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="updateDmsBaseShutType" parameterType="DmsBaseShutType">
        update dms_base_shut_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeCode != null">type_code = #{typeCode},</if>
            <if test="shutTypeName != null and shutTypeName != ''">shut_type_name = #{shutTypeName},</if>
            <if test="isFlag != null and isFlag != ''">is_flag = #{isFlag},</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 shut_type_id = #{shutTypeId}
    </update>

    <delete id="deleteDmsBaseShutTypeByShutTypeId" parameterType="Long">
        delete from dms_base_shut_type where shut_type_id = #{shutTypeId}
    </delete>

    <delete id="deleteDmsBaseShutTypeByShutTypeIds" parameterType="String">
        delete from dms_base_shut_type where shut_type_id in 
        <foreach item="shutTypeId" collection="array" open="(" separator="," close=")">
            #{shutTypeId}
        </foreach>
    </delete>
</mapper>