<?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.BaseSupplierMapper">
	
	<resultMap type="BaseSupplier" id="BaseSupplierResult">
		<result property="supplierId"	column="supplier_id"	/>
		<result property="supplierCode"	column="supplier_code"	/>
		<result property="zhDesc"	column="zh_desc"	/>
		<result property="enDesc"	column="en_desc"	/>
		<result property="supplierType"	column="supplier_type"	/>
		<result property="accountNumber"	column="account_number"	/>
		<result property="licenceNumber"	column="licence_number"	/>
		<result property="businessScope"	column="business_scope"	/>
		<result property="province"	column="province"	/>
		<result property="city"	column="city"	/>
		<result property="area"	column="area"	/>
		<result property="address"	column="address"	/>
		<result property="postcode"	column="postcode"	/>
		<result property="contact"	column="contact"	/>
		<result property="contactPhone"	column="contact_phone"	/>
		<result property="contactPosition"	column="contact_position"	/>
		<result property="contactEmail"	column="contact_email"	/>
		<result property="activeFlag"	column="active_flag"	/>
		<result property="userDefined1"	column="user_defined1"	/>
		<result property="userDefined2"	column="user_defined2"	/>
		<result property="userDefined3"	column="user_defined3"	/>
		<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="remark"	column="remark"	/>
	</resultMap>

	<sql id="selectBaseSupplierVo">
		select supplier_id, supplier_code, zh_desc, en_desc, supplier_type, account_number, licence_number, business_scope, province, city, area, address, postcode, contact, contact_phone, contact_position, contact_email, active_flag, user_defined1, user_defined2, user_defined3, create_by, create_time, update_by, update_time, remark from base_supplier
	</sql>

	<select id="selectBaseSupplierList" parameterType="BaseSupplier" resultMap="BaseSupplierResult">
		<include refid="selectBaseSupplierVo"/>
		<where>  
			<if test="supplierCode != null  and supplierCode != ''"> and supplier_code = #{supplierCode}</if>
			<if test="zhDesc != null  and zhDesc != ''"> and zh_desc = #{zhDesc}</if>
			<if test="enDesc != null  and enDesc != ''"> and en_desc = #{enDesc}</if>
			<if test="supplierType != null  and supplierType != ''"> and supplier_type = #{supplierType}</if>
			<if test="accountNumber != null  and accountNumber != ''"> and account_number = #{accountNumber}</if>
			<if test="licenceNumber != null  and licenceNumber != ''"> and licence_number = #{licenceNumber}</if>
			<if test="businessScope != null  and businessScope != ''"> and business_scope = #{businessScope}</if>
			<if test="province != null  and province != ''"> and province = #{province}</if>
			<if test="city != null  and city != ''"> and city = #{city}</if>
			<if test="area != null  and area != ''"> and area = #{area}</if>
			<if test="address != null  and address != ''"> and address = #{address}</if>
			<if test="postcode != null  and postcode != ''"> and postcode = #{postcode}</if>
			<if test="contact != null  and contact != ''"> and contact = #{contact}</if>
			<if test="contactPhone != null  and contactPhone != ''"> and contact_phone = #{contactPhone}</if>
			<if test="contactPosition != null  and contactPosition != ''"> and contact_position = #{contactPosition}</if>
			<if test="contactEmail != null  and contactEmail != ''"> and contact_email = #{contactEmail}</if>
			<if test="activeFlag != null  and activeFlag != ''"> and active_flag = #{activeFlag}</if>
			<if test="userDefined1 != null  and userDefined1 != ''"> and user_defined1 = #{userDefined1}</if>
			<if test="userDefined2 != null  and userDefined2 != ''"> and user_defined2 = #{userDefined2}</if>
			<if test="userDefined3 != null  and userDefined3 != ''"> and user_defined3 = #{userDefined3}</if>
		</where>
	</select>
	
	<select id="selectBaseSupplierBySupplierId" parameterType="String" resultMap="BaseSupplierResult">
		<include refid="selectBaseSupplierVo"/>
		where supplier_id = #{supplierId}
	</select>
		
	<insert id="insertBaseSupplier" parameterType="BaseSupplier">
		insert into base_supplier
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="supplierId != null">supplier_id,</if>
			<if test="supplierCode != null and supplierCode != ''">supplier_code,</if>
			<if test="zhDesc != null and zhDesc != ''">zh_desc,</if>
			<if test="enDesc != null">en_desc,</if>
			<if test="supplierType != null">supplier_type,</if>
			<if test="accountNumber != null">account_number,</if>
			<if test="licenceNumber != null">licence_number,</if>
			<if test="businessScope != null">business_scope,</if>
			<if test="province != null">province,</if>
			<if test="city != null">city,</if>
			<if test="area != null">area,</if>
			<if test="address != null">address,</if>
			<if test="postcode != null">postcode,</if>
			<if test="contact != null">contact,</if>
			<if test="contactPhone != null">contact_phone,</if>
			<if test="contactPosition != null">contact_position,</if>
			<if test="contactEmail != null">contact_email,</if>
			<if test="activeFlag != null and activeFlag != ''">active_flag,</if>
			<if test="userDefined1 != null">user_defined1,</if>
			<if test="userDefined2 != null">user_defined2,</if>
			<if test="userDefined3 != null">user_defined3,</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="remark != null">remark,</if>
		 </trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="supplierId != null">#{supplierId},</if>
			<if test="supplierCode != null and supplierCode != ''">#{supplierCode},</if>
			<if test="zhDesc != null and zhDesc != ''">#{zhDesc},</if>
			<if test="enDesc != null">#{enDesc},</if>
			<if test="supplierType != null">#{supplierType},</if>
			<if test="accountNumber != null">#{accountNumber},</if>
			<if test="licenceNumber != null">#{licenceNumber},</if>
			<if test="businessScope != null">#{businessScope},</if>
			<if test="province != null">#{province},</if>
			<if test="city != null">#{city},</if>
			<if test="area != null">#{area},</if>
			<if test="address != null">#{address},</if>
			<if test="postcode != null">#{postcode},</if>
			<if test="contact != null">#{contact},</if>
			<if test="contactPhone != null">#{contactPhone},</if>
			<if test="contactPosition != null">#{contactPosition},</if>
			<if test="contactEmail != null">#{contactEmail},</if>
			<if test="activeFlag != null and activeFlag != ''">#{activeFlag},</if>
			<if test="userDefined1 != null">#{userDefined1},</if>
			<if test="userDefined2 != null">#{userDefined2},</if>
			<if test="userDefined3 != null">#{userDefined3},</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="remark != null">#{remark},</if>
		 </trim>
	</insert>

	<update id="updateBaseSupplier" parameterType="BaseSupplier">
		update base_supplier
		<trim prefix="SET" suffixOverrides=",">
			<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
			<if test="zhDesc != null and zhDesc != ''">zh_desc = #{zhDesc},</if>
			<if test="enDesc != null">en_desc = #{enDesc},</if>
			<if test="supplierType != null">supplier_type = #{supplierType},</if>
			<if test="accountNumber != null">account_number = #{accountNumber},</if>
			<if test="licenceNumber != null">licence_number = #{licenceNumber},</if>
			<if test="businessScope != null">business_scope = #{businessScope},</if>
			<if test="province != null">province = #{province},</if>
			<if test="city != null">city = #{city},</if>
			<if test="area != null">area = #{area},</if>
			<if test="address != null">address = #{address},</if>
			<if test="postcode != null">postcode = #{postcode},</if>
			<if test="contact != null">contact = #{contact},</if>
			<if test="contactPhone != null">contact_phone = #{contactPhone},</if>
			<if test="contactPosition != null">contact_position = #{contactPosition},</if>
			<if test="contactEmail != null">contact_email = #{contactEmail},</if>
			<if test="activeFlag != null and activeFlag != ''">active_flag = #{activeFlag},</if>
			<if test="userDefined1 != null">user_defined1 = #{userDefined1},</if>
			<if test="userDefined2 != null">user_defined2 = #{userDefined2},</if>
			<if test="userDefined3 != null">user_defined3 = #{userDefined3},</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="remark != null">remark = #{remark},</if>
		</trim>
		where supplier_id = #{supplierId}
	</update>

	<delete id="deleteBaseSupplierBySupplierId" parameterType="String">
		delete from base_supplier where supplier_id = #{supplierId}
	</delete>

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