<?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.goldenwater.slaj.eme.mapper.BusiDrillRecordMapper">
    <resultMap type="com.goldenwater.slaj.eme.domain.BusiDrillRecord" id="BusiDrillRecordResult">
        <result property="drGuid" column="dr_guid"/>
        <result property="basicId" column="basic_id"/>
        <result property="drillType" column="drill_type"/>
        <result property="drillTime" column="drill_time"/>
        <result property="partakeNum" column="partake_num"/>
        <result property="partakeOrg" column="partake_org"/>
        <result property="orgGuid" column="org_guid"/>
        <result property="creperGuid" column="creper_guid"/>
        <result property="createTime" column="create_time"/>
        <result property="updperGuid" column="updper_guid"/>
        <result property="updateTime" column="update_time"/>
        <result property="drillName" column="drill_name"/>
        <result property="pdrGuid" column="pdr_guid"/>
        <result property="rdb" column="rdb"/>
        <result property="corStatus" column="cor_status"/>
    </resultMap>
    <sql id="selectBusiDrillRecordVo">
        select dr_guid, basic_id, drill_type, drill_time, partake_num, partake_org,
               org_guid, creper_guid, create_time, updper_guid, update_time,
               drill_name, pdr_guid, rdb, cor_status
        from t_busi_drill_record
    </sql>
    <select id="selectBusiDrillRecordByGuid" parameterType="String" resultMap="BusiDrillRecordResult">
        <include refid="selectBusiDrillRecordVo"/>
        where dr_guid = #{drGuid}
    </select>
    <select id="selectBusiDrillRecordList" parameterType="com.goldenwater.slaj.eme.domain.BusiDrillRecord" resultMap="BusiDrillRecordResult">
        <include refid="selectBusiDrillRecordVo"/>
        <where>
            <if test="basicId != null and basicId != ''">AND basic_id = #{basicId}</if>
            <if test="drillName != null and drillName != ''">AND drill_name like concat('%', #{drillName}, '%')</if>
            <if test="drillType != null and drillType != ''">AND drill_type = #{drillType}</if>
        </where>
    </select>
    <insert id="insertBusiDrillRecord" parameterType="com.goldenwater.slaj.eme.domain.BusiDrillRecord">
        insert into t_busi_drill_record (
            dr_guid, basic_id, drill_type, drill_time, partake_num, partake_org,
            org_guid, creper_guid, create_time, updper_guid, update_time,
            drill_name, pdr_guid, rdb, cor_status
        ) values (
            #{drGuid}, #{basicId}, #{drillType}, #{drillTime}, #{partakeNum}, #{partakeOrg},
            #{orgGuid}, #{creperGuid}, #{createTime}, #{updperGuid}, #{updateTime},
            #{drillName}, #{pdrGuid}, #{rdb}, #{corStatus}
        )
    </insert>
    <update id="updateBusiDrillRecord" parameterType="com.goldenwater.slaj.eme.domain.BusiDrillRecord">
        update t_busi_drill_record
        <set>
            <if test="basicId != null">basic_id = #{basicId},</if>
            <if test="drillType != null">drill_type = #{drillType},</if>
            <if test="drillTime != null">drill_time = #{drillTime},</if>
            <if test="partakeNum != null">partake_num = #{partakeNum},</if>
            <if test="partakeOrg != null">partake_org = #{partakeOrg},</if>
            <if test="orgGuid != null">org_guid = #{orgGuid},</if>
            <if test="creperGuid != null">creper_guid = #{creperGuid},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updperGuid != null">updper_guid = #{updperGuid},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="drillName != null">drill_name = #{drillName},</if>
            <if test="pdrGuid != null">pdr_guid = #{pdrGuid},</if>
            <if test="rdb != null">rdb = #{rdb},</if>
            <if test="corStatus != null">cor_status = #{corStatus},</if>
        </set>
        where dr_guid = #{drGuid}
    </update>
    <delete id="deleteBusiDrillRecordByGuid" parameterType="String">
        delete from t_busi_drill_record where dr_guid = #{drGuid}
    </delete>
    <delete id="deleteBusiDrillRecordByGuids" parameterType="String">
        delete from t_busi_drill_record where dr_guid in
        <foreach item="drGuid" collection="array" open="(" separator="," close=")">
            #{drGuid}
        </foreach>
    </delete>
</mapper>
