<?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.ruoyi.kaohe.mapper.KhEmpItemMapper">
    
    <resultMap type="KhEmpItem" id="KhEmpItemResult">
        <result property="id"    column="id"    />
        <result property="examineId"    column="examine_id"    />
        <result property="khitemId"    column="khitem_id"    />
        <result property="empId"    column="emp_id"    />
        <result property="empName"    column="emp_name"    />
        <result property="score"    column="score"    />
        <result property="date"    column="date"    />
        <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="selectKhEmpItemVo">
        select id, examine_id, khitem_id, emp_id, emp_name, score, date, create_by, create_time, update_by, update_time, remark from kh_emp_item
    </sql>

    <select id="selectKhEmpItemList" parameterType="KhEmpItem" resultMap="KhEmpItemResult">
        <include refid="selectKhEmpItemVo"/>
        <where>  
            <if test="examineId != null "> and examine_id = #{examineId}</if>
            <if test="khitemId != null "> and khitem_id = #{khitemId}</if>
            <if test="empId != null "> and emp_id = #{empId}</if>
            <if test="empName != null  and empName != ''"> and emp_name like concat('%', #{empName}, '%')</if>
            <if test="score != null "> and score = #{score}</if>
            <if test="date != null "> and date = #{date}</if>
        </where>
    </select>
    
    <select id="selectKhEmpItemById" parameterType="Long" resultMap="KhEmpItemResult">
        <include refid="selectKhEmpItemVo"/>
        where id = #{id}
    </select>

    <insert id="insertKhEmpItem" parameterType="KhEmpItem" useGeneratedKeys="true" keyProperty="id">
        insert into kh_emp_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="examineId != null">examine_id,</if>
            <if test="khitemId != null">khitem_id,</if>
            <if test="empId != null">emp_id,</if>
            <if test="empName != null and empName != ''">emp_name,</if>
            <if test="score != null">score,</if>
            <if test="date != null">date,</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="examineId != null">#{examineId},</if>
            <if test="khitemId != null">#{khitemId},</if>
            <if test="empId != null">#{empId},</if>
            <if test="empName != null and empName != ''">#{empName},</if>
            <if test="score != null">#{score},</if>
            <if test="date != null">#{date},</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="updateKhEmpItem" parameterType="KhEmpItem">
        update kh_emp_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="examineId != null">examine_id = #{examineId},</if>
            <if test="khitemId != null">khitem_id = #{khitemId},</if>
            <if test="empId != null">emp_id = #{empId},</if>
            <if test="empName != null and empName != ''">emp_name = #{empName},</if>
            <if test="score != null">score = #{score},</if>
            <if test="date != null">date = #{date},</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="deleteKhEmpItemById" parameterType="Long">
        delete from kh_emp_item where id = #{id}
    </delete>

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