<?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.yanzhu.manage.mapper.BusExamUserMapper">
    
    <resultMap type="BusExamUser" id="BusExamUserResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="projectId"    column="project_id"    />
        <result property="userId"    column="user_id"    />
        <result property="examTitle"    column="exam_title"    />
        <result property="examType"    column="exam_type"    />
        <result property="craftType"    column="craft_type"    />
        <result property="craftPost"    column="craft_post"    />
        <result property="singleNum"    column="single_num"    />
        <result property="multipleNum"    column="multiple_num"    />
        <result property="estimateNum"    column="estimate_num"    />
        <result property="userMark"    column="user_mark"    />
        <result property="resStatus"    column="res_status"    />
        <result property="useTimes"    column="use_times"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBusExamUserVo">
        select id, dept_id, project_id, user_id, exam_title, exam_type, craft_type, craft_post, single_num, multiple_num, estimate_num, user_mark, res_status, use_times, is_del, create_by, create_time, update_by, update_time, remark from bus_exam_user
    </sql>

    <select id="selectBusExamUserList" parameterType="BusExamUser" resultMap="BusExamUserResult">
        <include refid="selectBusExamUserVo"/>
        <where>  
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="projectId != null "> and project_id = #{projectId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="examTitle != null  and examTitle != ''"> and exam_title = #{examTitle}</if>
            <if test="examType != null  and examType != ''"> and exam_type = #{examType}</if>
            <if test="craftType != null  and craftType != ''"> and craft_type = #{craftType}</if>
            <if test="craftPost != null  and craftPost != ''"> and craft_post = #{craftPost}</if>
            <if test="singleNum != null  and singleNum != ''"> and single_num = #{singleNum}</if>
            <if test="multipleNum != null  and multipleNum != ''"> and multiple_num = #{multipleNum}</if>
            <if test="estimateNum != null  and estimateNum != ''"> and estimate_num = #{estimateNum}</if>
            <if test="userMark != null "> and user_mark = #{userMark}</if>
            <if test="resStatus != null "> and res_status = #{resStatus}</if>
            <if test="useTimes != null  and useTimes != ''"> and use_times = #{useTimes}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectBusExamUserById" parameterType="Long" resultMap="BusExamUserResult">
        <include refid="selectBusExamUserVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBusExamUser" parameterType="BusExamUser" useGeneratedKeys="true" keyProperty="id">
        insert into bus_exam_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="projectId != null">project_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="examTitle != null">exam_title,</if>
            <if test="examType != null">exam_type,</if>
            <if test="craftType != null">craft_type,</if>
            <if test="craftPost != null">craft_post,</if>
            <if test="singleNum != null">single_num,</if>
            <if test="multipleNum != null">multiple_num,</if>
            <if test="estimateNum != null">estimate_num,</if>
            <if test="userMark != null">user_mark,</if>
            <if test="resStatus != null">res_status,</if>
            <if test="useTimes != null">use_times,</if>
            <if test="isDel != null">is_del,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="examTitle != null">#{examTitle},</if>
            <if test="examType != null">#{examType},</if>
            <if test="craftType != null">#{craftType},</if>
            <if test="craftPost != null">#{craftPost},</if>
            <if test="singleNum != null">#{singleNum},</if>
            <if test="multipleNum != null">#{multipleNum},</if>
            <if test="estimateNum != null">#{estimateNum},</if>
            <if test="userMark != null">#{userMark},</if>
            <if test="resStatus != null">#{resStatus},</if>
            <if test="useTimes != null">#{useTimes},</if>
            <if test="isDel != null">#{isDel},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBusExamUser" parameterType="BusExamUser">
        update bus_exam_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="projectId != null">project_id = #{projectId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="examTitle != null">exam_title = #{examTitle},</if>
            <if test="examType != null">exam_type = #{examType},</if>
            <if test="craftType != null">craft_type = #{craftType},</if>
            <if test="craftPost != null">craft_post = #{craftPost},</if>
            <if test="singleNum != null">single_num = #{singleNum},</if>
            <if test="multipleNum != null">multiple_num = #{multipleNum},</if>
            <if test="estimateNum != null">estimate_num = #{estimateNum},</if>
            <if test="userMark != null">user_mark = #{userMark},</if>
            <if test="resStatus != null">res_status = #{resStatus},</if>
            <if test="useTimes != null">use_times = #{useTimes},</if>
            <if test="isDel != null">is_del = #{isDel},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusExamUserById" parameterType="Long">
        delete from bus_exam_user where id = #{id}
    </delete>

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