<?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.staffing.custom.mapper.StTransferRecordMapper">

    <resultMap type="StTransferRecord" id="StTransferRecordResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_id"    />
        <result property="taskName"    column="task_name"    />
        <result property="transferNo"    column="transfer_no"    />
        <result property="countPrice"    column="count_price"    />
        <result property="employeeIds"    column="employee_ids"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="payStatus"    column="pay_status"    />
    </resultMap>

    <sql id="selectStTransferRecordVo">
        select id, task_id, task_name, transfer_no, count_price, employee_ids, create_time, update_time, pay_status from st_transfer_record
    </sql>

    <select id="selectStTransferRecordList" parameterType="StTransferRecord" resultMap="StTransferRecordResult">
        <include refid="selectStTransferRecordVo"/>
        <where>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="taskName != null  and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
            <if test="transferNo != null  and transferNo != ''"> and transfer_no = #{transferNo}</if>
            <if test="countPrice != null  and countPrice != ''"> and count_price = #{countPrice}</if>
            <if test="employeeIds != null  and employeeIds != ''"> and employee_ids = #{employeeIds}</if>
            <if test="payStatus != null "> and pay_status = #{payStatus}</if>
        </where>
    </select>

    <select id="selectStTransferRecordById" parameterType="Long" resultMap="StTransferRecordResult">
        <include refid="selectStTransferRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertStTransferRecord" parameterType="StTransferRecord" useGeneratedKeys="true" keyProperty="id">
        insert into st_transfer_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="taskName != null">task_name,</if>
            <if test="transferNo != null">transfer_no,</if>
            <if test="countPrice != null">count_price,</if>
            <if test="employeeIds != null">employee_ids,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="payStatus != null">pay_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="taskName != null">#{taskName},</if>
            <if test="transferNo != null">#{transferNo},</if>
            <if test="countPrice != null">#{countPrice},</if>
            <if test="employeeIds != null">#{employeeIds},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="payStatus != null">#{payStatus},</if>
        </trim>
    </insert>

    <update id="updateStTransferRecord" parameterType="StTransferRecord">
        update st_transfer_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="taskName != null">task_name = #{taskName},</if>
            <if test="transferNo != null">transfer_no = #{transferNo},</if>
            <if test="countPrice != null">count_price = #{countPrice},</if>
            <if test="employeeIds != null">employee_ids = #{employeeIds},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteStTransferRecordById" parameterType="Long">
        delete from st_transfer_record where id = #{id}
    </delete>

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