<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.business.dao.AdjustShiftPersonDAO">
    <resultMap id="AdjustShiftPersonMap" type="com.jpsoft.shinestar.modules.business.entity.AdjustShiftPerson">
        <id property="id" column="id_"/>
        <result property="adjustShiftId" column="adjust_shift_id"/>
        <result property="personPopedomId" column="person_popedom_id"/>
        <result property="schedulingId" column="scheduling_id"/>
        <result property="newShiftId" column="new_shift_id"/>
        <result property="newShiftNumber" column="new_shift_number"/>
        <result property="oldShiftId" column="old_shift_id"/>
        <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"/>
    </resultMap>

    <insert id="insert" parameterType="com.jpsoft.shinestar.modules.business.entity.AdjustShiftPerson">
        <!--
        <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
            select sys_guid() from dual
        </selectKey>
        -->
        <![CDATA[
		insert into business_adjust_shift_person
	    (id_,adjust_shift_id,person_popedom_id,scheduling_id,new_shift_id,new_shift_number,old_shift_id,create_by,create_time,update_by,update_time,
	    del_flag)
		values
		(
			#{id,jdbcType=VARCHAR}
            ,#{adjustShiftId,jdbcType=VARCHAR}
			,#{personPopedomId,jdbcType=VARCHAR}
            ,#{schedulingId,jdbcType=VARCHAR}
            ,#{newShiftId,jdbcType=VARCHAR}
            ,#{newShiftNumber,jdbcType=VARCHAR}
            ,#{oldShiftId,jdbcType=VARCHAR}
			,#{createBy,jdbcType=VARCHAR}
			,#{createTime,jdbcType= TIMESTAMP }
			,#{updateBy,jdbcType=VARCHAR}
			,#{updateTime,jdbcType= TIMESTAMP }
			,#{delFlag,jdbcType= NUMERIC }
		)
	]]>
    </insert>
    <delete id="delete" parameterType="string">
        delete from business_adjust_shift_person where id_=#{id,jdbcType=VARCHAR}
    </delete>
    <update id="update" parameterType="com.jpsoft.shinestar.modules.business.entity.AdjustShiftPerson">
        update business_adjust_shift_person
        <set>
            <if test="adjustShiftId!=null">
                adjust_shift_id=#{adjustShiftId,jdbcType=VARCHAR},
            </if>
            <if test="personPopedomId!=null">
                person_popedom_id=#{personPopedomId,jdbcType=VARCHAR},
            </if>
            <if test="schedulingId!=null">
                scheduling_id=#{schedulingId,jdbcType=VARCHAR},
            </if>
            <if test="newShiftId!=null">
                new_shift_id=#{newShiftId,jdbcType=VARCHAR},
            </if>
            <if test="newShiftNumber!=null">
                new_shift_number=#{newShiftNumber,jdbcType=VARCHAR},
            </if>
            <if test="oldShiftId!=null">
                old_shift_id=#{oldShiftId,jdbcType=VARCHAR},
            </if>
            <if test="createBy!=null">
                create_by=#{createBy,jdbcType=VARCHAR},
            </if>
            <if test="createTime!=null">
                create_time=#{createTime,jdbcType= TIMESTAMP },
            </if>
            <if test="updateBy!=null">
                update_by=#{updateBy,jdbcType=VARCHAR},
            </if>
            <if test="updateTime!=null">
                update_time=#{updateTime,jdbcType= TIMESTAMP },
            </if>
            <if test="delFlag!=null">
                del_flag=#{delFlag,jdbcType= NUMERIC },
            </if>
        </set>
        where id_=#{id}
    </update>
    <select id="get" parameterType="string" resultMap="AdjustShiftPersonMap">
        select * from business_adjust_shift_person where id_=#{0}
    </select>
    <select id="exist" parameterType="string" resultType="int">
        select count(*) from business_adjust_shift_person where id_=#{0}
    </select>
    <select id="list" resultMap="AdjustShiftPersonMap">
        select * from business_adjust_shift_person
    </select>
    <select id="search" parameterType="hashmap" resultMap="AdjustShiftPersonMap">
        <![CDATA[
			select * from business_adjust_shift_person
		]]>
        <where>
            del_flag=0
            <if test="searchParams.id != null">
                and id_ = #{searchParams.id}
            </if>
            <if test="searchParams.personPopedomId != null">
                and person_popedom_id = #{searchParams.personPopedomId}
            </if>
        </where>
        <foreach item="sort" collection="sortList" open="order by" separator=",">
            ${sort.name} ${sort.order}
        </foreach>
    </select>

    <select id="findByAdjustShiftId" resultMap="AdjustShiftPersonMap">
        <![CDATA[
        select * from business_adjust_shift_person
        where del_flag = 0
        and adjust_shift_id = #{adjustShiftId}
        ]]>
    </select>
</mapper>