<?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.DmsBaseInspectStandardMapper">
    
    <resultMap type="DmsBaseInspectStandard" id="DmsBaseInspectStandardResult">
        <result property="inspectStandardId"    column="inspect_standard_id"    />
        <result property="standardCode"    column="standard_code"    />
        <result property="standardName"    column="standard_name"    />
        <result property="inspectObjective"    column="inspect_objective"    />
        <result property="inspectProjectId"    column="inspect_project_id"    />
        <result property="inspectItemCount"    column="inspect_item_count"    />
        <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="selectDmsBaseInspectStandardVo">
        select inspect_standard_id, standard_code, standard_name, inspect_objective,
               inspect_project_id, inspect_item_count, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_inspect_standard
    </sql>

    <select id="selectDmsBaseInspectStandardList" parameterType="DmsBaseInspectStandard" resultMap="DmsBaseInspectStandardResult">
        <include refid="selectDmsBaseInspectStandardVo"/>
        <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="inspectObjective != null  and inspectObjective != ''"> and inspect_objective = #{inspectObjective}</if>
            <if test="inspectProjectId != null "> and inspect_project_id = #{inspectProjectId}</if>
            <if test="inspectItemCount != null "> and inspect_item_count = #{inspectItemCount}</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsBaseInspectStandardByInspectStandardId" parameterType="Long" resultMap="DmsBaseInspectStandardResult">
        <include refid="selectDmsBaseInspectStandardVo"/>
        where inspect_standard_id = #{inspectStandardId}
    </select>
        
    <insert id="insertDmsBaseInspectStandard" parameterType="DmsBaseInspectStandard">
        <selectKey keyProperty="inspectStandardId" resultType="long" order="BEFORE">
            SELECT SEQ_DMS_INSPECT_STD.NEXTVAL FROM DUAL
        </selectKey>
        insert into dms_base_inspect_standard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inspectStandardId != null">inspect_standard_id,</if>
            <if test="standardCode != null">standard_code,</if>
            <if test="standardName != null and standardName != ''">standard_name,</if>
            <if test="inspectObjective != null">inspect_objective,</if>
            <if test="inspectProjectId != null">inspect_project_id,</if>
            <if test="inspectItemCount != null">inspect_item_count,</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="inspectStandardId != null">#{inspectStandardId},</if>
            <if test="standardCode != null">#{standardCode},</if>
            <if test="standardName != null and standardName != ''">#{standardName},</if>
            <if test="inspectObjective != null">#{inspectObjective},</if>
            <if test="inspectProjectId != null">#{inspectProjectId},</if>
            <if test="inspectItemCount != null">#{inspectItemCount},</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="updateDmsBaseInspectStandard" parameterType="DmsBaseInspectStandard">
        update dms_base_inspect_standard
        <trim prefix="SET" suffixOverrides=",">
            <if test="standardCode != null">standard_code = #{standardCode},</if>
            <if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
            <if test="inspectObjective != null">inspect_objective = #{inspectObjective},</if>
            <if test="inspectProjectId != null">inspect_project_id = #{inspectProjectId},</if>
            <if test="inspectItemCount != null">inspect_item_count = #{inspectItemCount},</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 inspect_standard_id = #{inspectStandardId}
    </update>

    <delete id="deleteDmsBaseInspectStandardByInspectStandardId" parameterType="Long">
        delete from dms_base_inspect_standard where inspect_standard_id = #{inspectStandardId}
    </delete>

    <delete id="deleteDmsBaseInspectStandardByInspectStandardIds" parameterType="String">
        delete from dms_base_inspect_standard where inspect_standard_id in 
        <foreach item="inspectStandardId" collection="array" open="(" separator="," close=")">
            #{inspectStandardId}
        </foreach>
    </delete>
</mapper>