<?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.xinda.itsm.mapper.RegulationInfoMapper">
    
    <resultMap type="RegulationInfo" id="RegulationInfoResult">
        <result property="regulationId"    column="regulation_id"    />
        <result property="regulationCode"    column="regulation_code"    />
        <result property="regulationName"    column="regulation_name"    />
        <result property="regulationDescribe"    column="regulation_describe"    />
        <result property="regulationType"    column="regulation_type"    />
        <result property="docOssId"    column="doc_oss_id"    />
        <result property="uploadTime"    column="upload_time"    />
        <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="selectRegulationInfoVo">
        select regulation_id, regulation_code, regulation_name, regulation_describe, regulation_type, doc_oss_id, upload_time, remark, create_by, create_time, update_by, update_time from regulation_info
    </sql>

    <select id="selectRegulationInfoList" parameterType="RegulationInfo" resultMap="RegulationInfoResult">
        <include refid="selectRegulationInfoVo"/>
        <where>  
            <if test="regulationCode != null  and regulationCode != ''"> and regulation_code = #{regulationCode}</if>
            <if test="regulationName != null  and regulationName != ''"> and regulation_name like concat('%', #{regulationName}, '%')</if>
            <if test="regulationDescribe != null  and regulationDescribe != ''"> and regulation_describe = #{regulationDescribe}</if>
            <if test="regulationType != null  and regulationType != ''"> and regulation_type = #{regulationType}</if>
            <if test="docOssId != null  and docOssId != ''"> and doc_oss_id = #{docOssId}</if>
            <if test="uploadTime != null "> and upload_time = #{uploadTime}</if>
        </where>
    </select>
    
    <select id="selectRegulationInfoByRegulationId" parameterType="Long" resultMap="RegulationInfoResult">
        <include refid="selectRegulationInfoVo"/>
        where regulation_id = #{regulationId}
    </select>
        
    <insert id="insertRegulationInfo" parameterType="RegulationInfo">
        insert into regulation_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="regulationId != null">regulation_id,</if>
            <if test="regulationCode != null">regulation_code,</if>
            <if test="regulationName != null">regulation_name,</if>
            <if test="regulationDescribe != null">regulation_describe,</if>
            <if test="regulationType != null">regulation_type,</if>
            <if test="docOssId != null">doc_oss_id,</if>
            <if test="uploadTime != null">upload_time,</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="regulationId != null">#{regulationId},</if>
            <if test="regulationCode != null">#{regulationCode},</if>
            <if test="regulationName != null">#{regulationName},</if>
            <if test="regulationDescribe != null">#{regulationDescribe},</if>
            <if test="regulationType != null">#{regulationType},</if>
            <if test="docOssId != null">#{docOssId},</if>
            <if test="uploadTime != null">#{uploadTime},</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="updateRegulationInfo" parameterType="RegulationInfo">
        update regulation_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="regulationCode != null">regulation_code = #{regulationCode},</if>
            <if test="regulationName != null">regulation_name = #{regulationName},</if>
            <if test="regulationDescribe != null">regulation_describe = #{regulationDescribe},</if>
            <if test="regulationType != null">regulation_type = #{regulationType},</if>
            <if test="docOssId != null">doc_oss_id = #{docOssId},</if>
            <if test="uploadTime != null">upload_time = #{uploadTime},</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 regulation_id = #{regulationId}
    </update>

    <delete id="deleteRegulationInfoByRegulationId" parameterType="Long">
        delete from regulation_info where regulation_id = #{regulationId}
    </delete>

    <delete id="deleteRegulationInfoByRegulationIds" parameterType="String">
        delete from regulation_info where regulation_id in 
        <foreach item="regulationId" collection="array" open="(" separator="," close=")">
            #{regulationId}
        </foreach>
    </delete>
</mapper>