<?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.KhPcEmpMapper">

    <resultMap type="KhPcEmp" id="KhPcEmpResult">
        <result property="id"    column="id"    />
        <result property="pcId"    column="pc_id"    />
        <result property="bkhdxType"    column="bkhdx_type"    />
        <result property="bkhdxId"    column="bkhdx_id"    />
        <result property="bkhdxName"    column="bkhdx_name"    />
        <result property="deptId"    column="dept_id"    />
        <result property="deptName"    column="dept_name"    />
        <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="selectKhPcEmpVo">
        select id, pc_id, bkhdx_type, bkhdx_id, bkhdx_name, dept_id, dept_name, create_by, create_time, update_by, update_time, remark from kh_pc_emp
    </sql>

    <select id="selectKhPcEmpList" parameterType="KhPcEmp" resultMap="KhPcEmpResult">
        <include refid="selectKhPcEmpVo"/>
        <where>
            <if test="pcId != null "> and pc_id = #{pcId}</if>
            <if test="bkhdxType != null  and bkhdxType != ''"> and bkhdx_type = #{bkhdxType}</if>
            <if test="bkhdxId != null "> and bkhdx_id = #{bkhdxId}</if>
            <if test="bkhdxName != null  and bkhdxName != ''"> and bkhdx_name like concat('%', #{bkhdxName}, '%')</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
        </where>
    </select>

    <select id="selectKhPcEmpById" parameterType="Long" resultMap="KhPcEmpResult">
        <include refid="selectKhPcEmpVo"/>
        where id = #{id}
    </select>

    <insert id="insertKhPcEmp" parameterType="KhPcEmp" useGeneratedKeys="true" keyProperty="id">
        insert into kh_pc_emp
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pcId != null">pc_id,</if>
            <if test="bkhdxType != null and bkhdxType != ''">bkhdx_type,</if>
            <if test="bkhdxId != null">bkhdx_id,</if>
            <if test="bkhdxName != null">bkhdx_name,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="deptName != null">dept_name,</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="pcId != null">#{pcId},</if>
            <if test="bkhdxType != null and bkhdxType != ''">#{bkhdxType},</if>
            <if test="bkhdxId != null">#{bkhdxId},</if>
            <if test="bkhdxName != null">#{bkhdxName},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="deptName != null">#{deptName},</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="updateKhPcEmp" parameterType="KhPcEmp">
        update kh_pc_emp
        <trim prefix="SET" suffixOverrides=",">
            <if test="pcId != null">pc_id = #{pcId},</if>
            <if test="bkhdxType != null and bkhdxType != ''">bkhdx_type = #{bkhdxType},</if>
            <if test="bkhdxId != null">bkhdx_id = #{bkhdxId},</if>
            <if test="bkhdxName != null">bkhdx_name = #{bkhdxName},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="deptName != null">dept_name = #{deptName},</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="deleteKhPcEmpById" parameterType="Long">
        delete from kh_pc_emp where id = #{id}
    </delete>

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