<?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.hw.dms.mapper.DmsBaseInspectProjectMapper">
    
    <resultMap type="DmsBaseInspectProject" id="DmsBaseInspectProjectResult">
        <result property="inspectProjectId"    column="inspect_project_id"    />
        <result property="inspectProjectCode"    column="inspect_project_code"    />
        <result property="inspectProject"    column="inspect_project"    />
        <result property="inspectType"    column="inspect_type"    />
        <result property="recordMethod"    column="record_method"    />
        <result property="upLimit"    column="up_limit"    />
        <result property="lowLimit"    column="low_limit"    />
        <result property="defValue"    column="def_value"    />
        <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="selectDmsBaseInspectProjectVo">
        select inspect_project_id, inspect_project_code, inspect_project, inspect_type, record_method, up_limit, low_limit, def_value, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_inspect_project
    </sql>

    <select id="selectDmsBaseInspectProjectList" parameterType="DmsBaseInspectProject" resultMap="DmsBaseInspectProjectResult">
        <include refid="selectDmsBaseInspectProjectVo"/>
        <where>  
            <if test="inspectProjectCode != null  and inspectProjectCode != ''"> and inspect_project_code = #{inspectProjectCode}</if>
            <if test="inspectProject != null  and inspectProject != ''"> and inspect_project = #{inspectProject}</if>
            <if test="inspectType != null  and inspectType != ''"> and inspect_type = #{inspectType}</if>
            <if test="recordMethod != null  and recordMethod != ''"> and record_method = #{recordMethod}</if>
            <if test="upLimit != null "> and up_limit = #{upLimit}</if>
            <if test="lowLimit != null "> and low_limit = #{lowLimit}</if>
            <if test="defValue != null "> and def_value = #{defValue}</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsBaseInspectProjectByInspectProjectId" parameterType="Long" resultMap="DmsBaseInspectProjectResult">
        <include refid="selectDmsBaseInspectProjectVo"/>
        where inspect_project_id = #{inspectProjectId}
    </select>
        
    <insert id="insertDmsBaseInspectProject" parameterType="DmsBaseInspectProject" useGeneratedKeys="true" keyProperty="inspectProjectId">
        insert into dms_base_inspect_project
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="inspectProjectCode != null">inspect_project_code,</if>
            <if test="inspectProject != null and inspectProject != ''">inspect_project,</if>
            <if test="inspectType != null and inspectType != ''">inspect_type,</if>
            <if test="recordMethod != null">record_method,</if>
            <if test="upLimit != null">up_limit,</if>
            <if test="lowLimit != null">low_limit,</if>
            <if test="defValue != null">def_value,</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="inspectProjectCode != null">#{inspectProjectCode},</if>
            <if test="inspectProject != null and inspectProject != ''">#{inspectProject},</if>
            <if test="inspectType != null and inspectType != ''">#{inspectType},</if>
            <if test="recordMethod != null">#{recordMethod},</if>
            <if test="upLimit != null">#{upLimit},</if>
            <if test="lowLimit != null">#{lowLimit},</if>
            <if test="defValue != null">#{defValue},</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="updateDmsBaseInspectProject" parameterType="DmsBaseInspectProject">
        update dms_base_inspect_project
        <trim prefix="SET" suffixOverrides=",">
            <if test="inspectProjectCode != null">inspect_project_code = #{inspectProjectCode},</if>
            <if test="inspectProject != null and inspectProject != ''">inspect_project = #{inspectProject},</if>
            <if test="inspectType != null and inspectType != ''">inspect_type = #{inspectType},</if>
            <if test="recordMethod != null">record_method = #{recordMethod},</if>
            <if test="upLimit != null">up_limit = #{upLimit},</if>
            <if test="lowLimit != null">low_limit = #{lowLimit},</if>
            <if test="defValue != null">def_value = #{defValue},</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_project_id = #{inspectProjectId}
    </update>

    <delete id="deleteDmsBaseInspectProjectByInspectProjectId" parameterType="Long">
        delete from dms_base_inspect_project where inspect_project_id = #{inspectProjectId}
    </delete>

    <delete id="deleteDmsBaseInspectProjectByInspectProjectIds" parameterType="String">
        delete from dms_base_inspect_project where inspect_project_id in 
        <foreach item="inspectProjectId" collection="array" open="(" separator="," close=")">
            #{inspectProjectId}
        </foreach>
    </delete>
</mapper>