<?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.StandardInfoMapper">
    
    <resultMap type="StandardInfo" id="StandardInfoResult">
        <result property="standardId"    column="standard_id"    />
        <result property="standardCode"    column="standard_code"    />
        <result property="standardName"    column="standard_name"    />
        <result property="standardDescribe"    column="standard_describe"    />
        <result property="docOssId"    column="doc_oss_id"    />
        <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="selectStandardInfoVo">
        select standard_id, standard_code, standard_name, standard_describe, doc_oss_id, remark, create_by, create_time, update_by, update_time from standard_info
    </sql>

    <select id="selectStandardInfoList" parameterType="StandardInfo" resultMap="StandardInfoResult">
        <include refid="selectStandardInfoVo"/>
        <where>  
            <if test="standardCode != null  and standardCode != ''"> and standard_code = #{standardCode}</if>
            <if test="standardName != null  and standardName != ''"> and standard_name like concat('%', #{standardName}, '%')</if>
            <if test="standardDescribe != null  and standardDescribe != ''"> and standard_describe = #{standardDescribe}</if>
            <if test="docOssId != null  and docOssId != ''"> and doc_oss_id = #{docOssId}</if>
        </where>
    </select>
    
    <select id="selectStandardInfoByStandardId" parameterType="Long" resultMap="StandardInfoResult">
        <include refid="selectStandardInfoVo"/>
        where standard_id = #{standardId}
    </select>
        
    <insert id="insertStandardInfo" parameterType="StandardInfo">
        insert into standard_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="standardId != null">standard_id,</if>
            <if test="standardCode != null">standard_code,</if>
            <if test="standardName != null">standard_name,</if>
            <if test="standardDescribe != null">standard_describe,</if>
            <if test="docOssId != null">doc_oss_id,</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="standardId != null">#{standardId},</if>
            <if test="standardCode != null">#{standardCode},</if>
            <if test="standardName != null">#{standardName},</if>
            <if test="standardDescribe != null">#{standardDescribe},</if>
            <if test="docOssId != null">#{docOssId},</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="updateStandardInfo" parameterType="StandardInfo">
        update standard_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="standardCode != null">standard_code = #{standardCode},</if>
            <if test="standardName != null">standard_name = #{standardName},</if>
            <if test="standardDescribe != null">standard_describe = #{standardDescribe},</if>
            <if test="docOssId != null">doc_oss_id = #{docOssId},</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 standard_id = #{standardId}
    </update>

    <delete id="deleteStandardInfoByStandardId" parameterType="Long">
        delete from standard_info where standard_id = #{standardId}
    </delete>

    <delete id="deleteStandardInfoByStandardIds" parameterType="String">
        delete from standard_info where standard_id in 
        <foreach item="standardId" collection="array" open="(" separator="," close=")">
            #{standardId}
        </foreach>
    </delete>
</mapper>