<?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.baseinfo.mapper.BaseShiftdetailInfoMapper">

    <resultMap type="BaseShiftdetailInfo" id="BaseShiftdetailInfoResult">
        <result property="shiftNo"    column="shift_no"    />
        <result property="postId"    column="post_id"    />
        <result property="empId"    column="emp_id"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <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="delFlag"    column="del_flag"    />
        <result property="postName"    column="post_name"    />
        <result property="empName"    column="emp_name"    />
    </resultMap>

    <sql id="selectBaseShiftdetailInfoVo">
        select shift_no, post_id, emp_id, status, remark, create_by, create_time, update_by, update_time, del_flag from base_shiftdetail_info
    </sql>

    <select id="selectBaseShiftdetailInfoList" parameterType="BaseShiftdetailInfo" resultMap="BaseShiftdetailInfoResult">
        select shift_no, t1.post_id,t3.post_name, t1.emp_id,t2.emp_name, t1.status, t1.remark, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.del_flag from base_shiftdetail_info t1
        left join base_employee_info t2 on t1.emp_id = t2.emp_id
        left join base_post_info t3 on t1.post_id = t3.post_id
        <where>
            <if test="status != null  and status != ''"> and t1.status = #{status}</if>
        </where>
    </select>

    <select id="selectBaseShiftdetailInfoById" parameterType="String" resultMap="BaseShiftdetailInfoResult">
        <include refid="selectBaseShiftdetailInfoVo"/>
        where shift_no = #{shiftNo}
    </select>

    <insert id="insertBaseShiftdetailInfo" parameterType="BaseShiftdetailInfo">
        insert into base_shiftdetail_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="shiftNo != null">shift_no,</if>
            <if test="postId != null">post_id,</if>
            <if test="empId != null">emp_id,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</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="delFlag != null">del_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="shiftNo != null">#{shiftNo},</if>
            <if test="postId != null">#{postId},</if>
            <if test="empId != null">#{empId},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</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="delFlag != null">#{delFlag},</if>
         </trim>
    </insert>

    <update id="updateBaseShiftdetailInfo" parameterType="BaseShiftdetailInfo">
        update base_shiftdetail_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="postId != null">post_id = #{postId},</if>
            <if test="empId != null">emp_id = #{empId},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</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="delFlag != null">del_flag = #{delFlag},</if>
        </trim>
        where shift_no = #{shiftNo}
    </update>

    <delete id="deleteBaseShiftdetailInfoById" parameterType="String">
        delete from base_shiftdetail_info where shift_no = #{shiftNo}
    </delete>

    <delete id="deleteBaseShiftdetailInfoByIds" parameterType="String">
        delete from base_shiftdetail_info where shift_no in
        <foreach item="shiftNo" collection="array" open="(" separator="," close=")">
            #{shiftNo}
        </foreach>
    </delete>

</mapper>
