<?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.supervision.grassrootsregistration.mapper.BdglDrillFuMapper">

    <resultMap type="BdglDrillFu" id="BdglDrillFuResult">
        <result property="id"    column="id"    />
        <result property="peopleName"    column="people_name"    />
        <result property="peopleId"    column="people_id"    />
        <result property="state"    column="state"    />
        <result property="trainingStatus"    column="training_status"    />
        <result property="drillid"    column="drillid"    />
    </resultMap>

    <sql id="selectBdglDrillFuVo">
        select id, people_name, people_id, state, training_status,drillid from bdgl_drill_fu
    </sql>

    <select id="selectBdglDrillFuList" parameterType="BdglDrillFu" resultMap="BdglDrillFuResult">
        <include refid="selectBdglDrillFuVo"/>
        <where>
            <if test="peopleName != null  and peopleName != ''"> and people_name like concat('%', #{peopleName}, '%')</if>
            <if test="peopleId != null "> and people_id = #{peopleId}</if>
            <if test="state != null  and state != ''"> and state = #{state}</if>
            <if test="trainingStatus != null  and trainingStatus != ''"> and training_status = #{trainingStatus}</if>
            <if test="drillid != null  and drillid != ''"> and drillid = #{drillid}</if>
        </where>
    </select>

    <select id="selectBdglDrillFuById" parameterType="Long" resultMap="BdglDrillFuResult">
        <include refid="selectBdglDrillFuVo"/>
        where id = #{id}
    </select>

    <insert id="insertBdglDrillFu" parameterType="BdglDrillFu">
        insert into bdgl_drill_fu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="peopleName != null">people_name,</if>
            <if test="peopleId != null">people_id,</if>
            <if test="state != null">state,</if>
            <if test="trainingStatus != null">training_status,</if>
            <if test="drillid != null">drillid,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="peopleName != null">#{peopleName},</if>
            <if test="peopleId != null">#{peopleId},</if>
            <if test="state != null">#{state},</if>
            <if test="trainingStatus != null">#{trainingStatus},</if>
            <if test="drillid != null">#{drillid},</if>
        </trim>
    </insert>

    <update id="updateBdglDrillFu" parameterType="BdglDrillFu">
        update bdgl_drill_fu
        <trim prefix="SET" suffixOverrides=",">
            <if test="peopleName != null">people_name = #{peopleName},</if>
            <if test="peopleId != null">people_id = #{peopleId},</if>
            <if test="state != null">state = #{state},</if>
            <if test="trainingStatus != null">training_status = #{trainingStatus},</if>
            <if test="drillid != null">drillid = #{drillid},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBdglDrillFuById" parameterType="Long">
        delete from bdgl_drill_fu where id = #{id}
    </delete>

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