<?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.report.mapper.ReportRepairMeasuresMapper">

    <resultMap type="ReportRepairMeasures" id="ReportRepairMeasuresResult">
        <result property="objId" column="obj_id"/>
        <result property="repairCode" column="repair_code"/>
        <result property="repairName" column="repair_name"/>
        <result property="processCode" column="process_code"/>
        <result property="isFlag" column="is_flag"/>
        <result property="createdBy" column="created_by"/>
        <result property="createdTime" column="created_time"/>
        <result property="updatedBy" column="updated_by"/>
        <result property="updatedTime" column="updated_time"/>
    </resultMap>

    <sql id="selectReportRepairMeasuresVo">
        select obj_id,
               repair_code,
               repair_name,
               process_code,
               is_flag,
               created_by,
               created_time,
               updated_by,
               updated_time
        from report_repair_measures
    </sql>

    <select id="selectReportRepairMeasuresList" parameterType="ReportRepairMeasures"
            resultMap="ReportRepairMeasuresResult">
        <include refid="selectReportRepairMeasuresVo"/>
        <where>
            <if test="repairCode != null  and repairCode != ''">and repair_code = #{repairCode}</if>
            <if test="repairName != null  and repairName != ''">and repair_name like concat(concat('%', #{repairName}),
                '%')
            </if>
            <if test="processCode != null  and processCode != ''">and process_code = #{processCode}</if>
            <if test="isFlag != null ">and is_flag = #{isFlag}</if>
            <if test="createdBy != null  and createdBy != ''">and created_by = #{createdBy}</if>
            <if test="createdTime != null ">and created_time = #{createdTime}</if>
            <if test="updatedBy != null  and updatedBy != ''">and updated_by = #{updatedBy}</if>
            <if test="updatedTime != null ">and updated_time = #{updatedTime}</if>
        </where>
    </select>

    <select id="selectReportRepairMeasuresByObjId" parameterType="Long" resultMap="ReportRepairMeasuresResult">
        <include refid="selectReportRepairMeasuresVo"/>
        where obj_id = #{objId}
    </select>

    <insert id="insertReportRepairMeasures" parameterType="ReportRepairMeasures">
        <selectKey keyProperty="objId" resultType="long" order="BEFORE">
            SELECT seq_report_repair_measures.NEXTVAL as objId FROM DUAL
        </selectKey>
        insert into report_repair_measures
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="objId != null">obj_id,</if>
            <if test="repairCode != null">repair_code,</if>
            <if test="repairName != null">repair_name,</if>
            <if test="processCode != null">process_code,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedTime != null">updated_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="objId != null">#{objId},</if>
            <if test="repairCode != null">#{repairCode},</if>
            <if test="repairName != null">#{repairName},</if>
            <if test="processCode != null">#{processCode},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
        </trim>
    </insert>

    <update id="updateReportRepairMeasures" parameterType="ReportRepairMeasures">
        update report_repair_measures
        <trim prefix="SET" suffixOverrides=",">
            <if test="repairCode != null">repair_code = #{repairCode},</if>
            <if test="repairName != null">repair_name = #{repairName},</if>
            <if test="processCode != null">process_code = #{processCode},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
        </trim>
        where obj_id = #{objId}
    </update>

    <delete id="deleteReportRepairMeasuresByObjId" parameterType="Long">
        delete
        from report_repair_measures
        where obj_id = #{objId}
    </delete>

    <delete id="deleteReportRepairMeasuresByObjIds" parameterType="String">
        delete from report_repair_measures where obj_id in
        <foreach item="objId" collection="array" open="(" separator="," close=")">
            #{objId}
        </foreach>
    </delete>
</mapper>