<?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.op.wms.mapper.BaseShiftsTMapper">
	
	<resultMap type="BaseShiftsT" id="BaseShiftsTResult">
		<result property="shiftId"	column="Shift_Id"	/>
		<result property="shiftCode"	column="Shift_Code"	/>
		<result property="shiftDesc"	column="Shift_Desc"	/>
		<result property="shiftDescGlobal"	column="Shift_Desc_Global"	/>
		<result property="shiftDescExtended"	column="Shift_Desc_Extended"	/>
		<result property="shiftStartTime"	column="Shift_Start_Time"	/>
		<result property="shiftEndTime"	column="Shift_End_Time"	/>
		<result property="createBy"	column="Create_By"	/>
		<result property="createDate"	column="Create_Date"	/>
		<result property="lastUpdateBy"	column="Last_Update_By"	/>
		<result property="lastUpdateDate"	column="Last_Update_Date"	/>
		<result property="Active"	column="Active"	/>
		<result property="enterpriseId"	column="Enterprise_Id"	/>
		<result property="enterpriseCode"	column="Enterprise_Code"	/>
		<result property="siteId"	column="Site_Id"	/>
		<result property="siteCode"	column="Site_Code"	/>
	</resultMap>

	<sql id="selectBaseShiftsTVo">
		select Shift_Id, Shift_Code, Shift_Desc, Shift_Desc_Global, Shift_Desc_Extended, Shift_Start_Time, Shift_End_Time, Create_By, Create_Date, Last_Update_By, Last_Update_Date, Active, Enterprise_Id, Enterprise_Code, Site_Id, Site_Code from base_shifts_t
	</sql>

	<select id="selectBaseShiftsTList" parameterType="BaseShiftsT" resultMap="BaseShiftsTResult">
		<include refid="selectBaseShiftsTVo"/>
		<where>  
			<if test="shiftCode != null  and shiftCode != ''"> and Shift_Code = #{shiftCode}</if>
			<if test="shiftDesc != null  and shiftDesc != ''"> and Shift_Desc = #{shiftDesc}</if>
			<if test="shiftDescGlobal != null  and shiftDescGlobal != ''"> and Shift_Desc_Global = #{shiftDescGlobal}</if>
			<if test="shiftDescExtended != null  and shiftDescExtended != ''"> and Shift_Desc_Extended = #{shiftDescExtended}</if>
			<if test="shiftStartTime != null  and shiftStartTime != ''"> and Shift_Start_Time = #{shiftStartTime}</if>
			<if test="shiftEndTime != null  and shiftEndTime != ''"> and Shift_End_Time = #{shiftEndTime}</if>
			<if test="createBy != null  and createBy != ''"> and Create_By = #{createBy}</if>
			<if test="createDate != null "> and Create_Date = #{createDate}</if>
			<if test="lastUpdateBy != null  and lastUpdateBy != ''"> and Last_Update_By = #{lastUpdateBy}</if>
			<if test="lastUpdateDate != null "> and Last_Update_Date = #{lastUpdateDate}</if>
			<if test="Active != null  and Active != ''"> and Active = #{Active}</if>
			<if test="enterpriseId != null  and enterpriseId != ''"> and Enterprise_Id = #{enterpriseId}</if>
			<if test="enterpriseCode != null  and enterpriseCode != ''"> and Enterprise_Code = #{enterpriseCode}</if>
			<if test="siteId != null  and siteId != ''"> and Site_Id = #{siteId}</if>
			<if test="siteCode != null  and siteCode != ''"> and Site_Code = #{siteCode}</if>
		</where>
	</select>
	
	<select id="selectBaseShiftsTByShiftId" parameterType="String" resultMap="BaseShiftsTResult">
		<include refid="selectBaseShiftsTVo"/>
		where Shift_Id = #{shiftId}
	</select>
		
	<insert id="insertBaseShiftsT" parameterType="BaseShiftsT">
		insert into base_shifts_t
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="shiftId != null">Shift_Id,</if>
			<if test="shiftCode != null">Shift_Code,</if>
			<if test="shiftDesc != null">Shift_Desc,</if>
			<if test="shiftDescGlobal != null">Shift_Desc_Global,</if>
			<if test="shiftDescExtended != null">Shift_Desc_Extended,</if>
			<if test="shiftStartTime != null">Shift_Start_Time,</if>
			<if test="shiftEndTime != null">Shift_End_Time,</if>
			<if test="createBy != null">Create_By,</if>
			<if test="createDate != null">Create_Date,</if>
			<if test="lastUpdateBy != null">Last_Update_By,</if>
			<if test="lastUpdateDate != null">Last_Update_Date,</if>
			<if test="Active != null">Active,</if>
			<if test="enterpriseId != null">Enterprise_Id,</if>
			<if test="enterpriseCode != null">Enterprise_Code,</if>
			<if test="siteId != null">Site_Id,</if>
			<if test="siteCode != null">Site_Code,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="shiftId != null">#{shiftId},</if>
			<if test="shiftCode != null">#{shiftCode},</if>
			<if test="shiftDesc != null">#{shiftDesc},</if>
			<if test="shiftDescGlobal != null">#{shiftDescGlobal},</if>
			<if test="shiftDescExtended != null">#{shiftDescExtended},</if>
			<if test="shiftStartTime != null">#{shiftStartTime},</if>
			<if test="shiftEndTime != null">#{shiftEndTime},</if>
			<if test="createBy != null">#{createBy},</if>
			<if test="createDate != null">#{createDate},</if>
			<if test="lastUpdateBy != null">#{lastUpdateBy},</if>
			<if test="lastUpdateDate != null">#{lastUpdateDate},</if>
			<if test="Active != null">#{Active},</if>
			<if test="enterpriseId != null">#{enterpriseId},</if>
			<if test="enterpriseCode != null">#{enterpriseCode},</if>
			<if test="siteId != null">#{siteId},</if>
			<if test="siteCode != null">#{siteCode},</if>
		 </trim>
	</insert>

	<update id="updateBaseShiftsT" parameterType="BaseShiftsT">
		update base_shifts_t
		<trim prefix="SET" suffixOverrides=",">
			<if test="shiftCode != null">Shift_Code = #{shiftCode},</if>
			<if test="shiftDesc != null">Shift_Desc = #{shiftDesc},</if>
			<if test="shiftDescGlobal != null">Shift_Desc_Global = #{shiftDescGlobal},</if>
			<if test="shiftDescExtended != null">Shift_Desc_Extended = #{shiftDescExtended},</if>
			<if test="shiftStartTime != null">Shift_Start_Time = #{shiftStartTime},</if>
			<if test="shiftEndTime != null">Shift_End_Time = #{shiftEndTime},</if>
			<if test="createBy != null">Create_By = #{createBy},</if>
			<if test="createDate != null">Create_Date = #{createDate},</if>
			<if test="lastUpdateBy != null">Last_Update_By = #{lastUpdateBy},</if>
			<if test="lastUpdateDate != null">Last_Update_Date = #{lastUpdateDate},</if>
			<if test="Active != null">Active = #{Active},</if>
			<if test="enterpriseId != null">Enterprise_Id = #{enterpriseId},</if>
			<if test="enterpriseCode != null">Enterprise_Code = #{enterpriseCode},</if>
			<if test="siteId != null">Site_Id = #{siteId},</if>
			<if test="siteCode != null">Site_Code = #{siteCode},</if>
		</trim>
		where Shift_Id = #{shiftId}
	</update>

	<delete id="deleteBaseShiftsTByShiftId" parameterType="String">
		delete from base_shifts_t where Shift_Id = #{shiftId}
	</delete>

	<delete id="deleteBaseShiftsTByShiftIds" parameterType="String">
		delete from base_shifts_t where Shift_Id in 
		<foreach item="shiftId" collection="array" open="(" separator="," close=")">
			#{shiftId}
		</foreach>
	</delete>

	<select id="queryAllStartTime" parameterType="String" resultMap="BaseShiftsTResult">
		select
	</select>

</mapper>