<?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.BaseProductGroupsTMapper">
	
	<resultMap type="BaseProductGroupsT" id="BaseProductGroupsTResult">
		<result property="pgId"	column="PG_Id"	/>
		<result property="pgCode"	column="PG_Code"	/>
		<result property="pgDesc"	column="PG_Desc"	/>
		<result property="pgDescGlobal"	column="PG_Desc_Global"	/>
		<result property="pgDescExtended"	column="PG_Desc_Extended"	/>
		<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="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="selectBaseProductGroupsTVo">
		select PG_Id, PG_Code, PG_Desc, PG_Desc_Global, PG_Desc_Extended, create_by, create_time, update_by, update_time, Active, Enterprise_Id, Enterprise_Code, Site_Id, Site_Code from base_product_groups_t
	</sql>

	<select id="selectBaseProductGroupsTList" parameterType="BaseProductGroupsT" resultMap="BaseProductGroupsTResult">
		<include refid="selectBaseProductGroupsTVo"/>
		<where>  
			<if test="pgCode != null  and pgCode != ''"> and PG_Code = #{pgCode}</if>
			<if test="pgDesc != null  and pgDesc != ''"> and PG_Desc = #{pgDesc}</if>
			<if test="pgDescGlobal != null  and pgDescGlobal != ''"> and PG_Desc_Global = #{pgDescGlobal}</if>
			<if test="pgDescExtended != null  and pgDescExtended != ''"> and PG_Desc_Extended = #{pgDescExtended}</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="selectBaseProductGroupsTByPgId" parameterType="String" resultMap="BaseProductGroupsTResult">
		<include refid="selectBaseProductGroupsTVo"/>
		where PG_Id = #{pgId}
	</select>
		
	<insert id="insertBaseProductGroupsT" parameterType="BaseProductGroupsT">
		insert into base_product_groups_t
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="pgId != null">PG_Id,</if>
			<if test="pgCode != null">PG_Code,</if>
			<if test="pgDesc != null and pgDesc != ''">PG_Desc,</if>
			<if test="pgDescGlobal != null and pgDescGlobal != ''">PG_Desc_Global,</if>
			<if test="pgDescExtended != null and pgDescExtended != ''">PG_Desc_Extended,</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="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="pgId != null">#{pgId},</if>
			<if test="pgCode != null">#{pgCode},</if>
			<if test="pgDesc != null and pgDesc != ''">#{pgDesc},</if>
			<if test="pgDescGlobal != null and pgDescGlobal != ''">#{pgDescGlobal},</if>
			<if test="pgDescExtended != null and pgDescExtended != ''">#{pgDescExtended},</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="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="updateBaseProductGroupsT" parameterType="BaseProductGroupsT">
		update base_product_groups_t
		<trim prefix="SET" suffixOverrides=",">
			<if test="pgCode != null">PG_Code = #{pgCode},</if>
			<if test="pgDesc != null and pgDesc != ''">PG_Desc = #{pgDesc},</if>
			<if test="pgDescGlobal != null and pgDescGlobal != ''">PG_Desc_Global = #{pgDescGlobal},</if>
			<if test="pgDescExtended != null and pgDescExtended != ''">PG_Desc_Extended = #{pgDescExtended},</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="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 PG_Id = #{pgId}
	</update>

	<delete id="deleteBaseProductGroupsTByPgId" parameterType="String">
		delete from base_product_groups_t where PG_Id = #{pgId}
	</delete>

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