<?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.base.dao.ParkingMerchantDAO">
	<resultMap id="ParkingMerchantMap" type="com.jpsoft.shinestar.modules.base.entity.ParkingMerchant">
		<id property="id" column="id_" />
			<result property="merchantNo" column="merchant_no" />
			<result property="merchantName" column="merchant_name" />
			<result property="companyId" column="company_id" />
			<result property="operatorNo" column="operator_no" />
			<result property="operatorPassword" column="operator_password" />
			<result property="type" column="type_" />
			<result property="reduce" column="reduce_" />
			<result property="openId" column="open_id" />
			<result property="delFlag" column="del_flag" />
			<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="companyName" column="company_name" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ParkingMerchant">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_parking_merchant
	    (id_,merchant_no,merchant_name,company_id,operator_no,operator_password,type_,reduce_,open_id,del_flag,create_by,create_time,update_by,update_time)
		values
		(
#{id,jdbcType=VARCHAR}
,#{merchantNo,jdbcType=VARCHAR}
,#{merchantName,jdbcType=VARCHAR}
,#{companyId,jdbcType=VARCHAR}
,#{operatorNo,jdbcType=VARCHAR}
,#{operatorPassword,jdbcType=VARCHAR}
,#{type,jdbcType=VARCHAR}
,#{reduce,jdbcType= NUMERIC }
,#{openId,jdbcType=VARCHAR}
,#{delFlag,jdbcType= NUMERIC }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_parking_merchant where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ParkingMerchant">
		update base_parking_merchant
		<set>
				<if test="merchantNo!=null">
		merchant_no=#{merchantNo,jdbcType=VARCHAR},
		</if>
				<if test="merchantName!=null">
		merchant_name=#{merchantName,jdbcType=VARCHAR},
		</if>
				<if test="companyId!=null">
		company_id=#{companyId,jdbcType=VARCHAR},
		</if>
				<if test="operatorNo!=null">
		operator_no=#{operatorNo,jdbcType=VARCHAR},
		</if>
				<if test="operatorPassword!=null">
		operator_password=#{operatorPassword,jdbcType=VARCHAR},
		</if>
				<if test="type!=null">
		type_=#{type,jdbcType=VARCHAR},
		</if>
				<if test="reduce!=null">
		reduce_=#{reduce,jdbcType= NUMERIC },
		</if>
				<if test="openId!=null">
		open_id=#{openId,jdbcType=VARCHAR},
		</if>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</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>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="ParkingMerchantMap">
		select
id_,merchant_no,merchant_name,company_id,operator_no,operator_password,type_,reduce_,open_id,del_flag,create_by,create_time,update_by,update_time		from base_parking_merchant where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_parking_merchant where id_=#{0}
	</select>
	<select id="list" resultMap="ParkingMerchantMap">
		select * from base_parking_merchant
	</select>
	<select id="search" parameterType="hashmap" resultMap="ParkingMerchantMap">
		<![CDATA[
			SELECT
				a.*,
				b.name_ AS company_name
			FROM
				base_parking_merchant a
				LEFT JOIN base_company_info b ON a.company_id = b.id_
		]]>
		<where>
			a.del_flag = 0
			<if test="searchParams.id != null">
				and a.ID_ like #{searchParams.id}
			</if>
			<if test="searchParams.companyId != null">
				and a.company_id = #{searchParams.companyId}
			</if>
			<if test="searchParams.type != null">
				and a.type_ = #{searchParams.type}
			</if>
			<if test="searchParams.merchantName != null">
				and a.merchant_name like #{searchParams.merchantName}
			</if>
			<if test="searchParams.parentCompanyCode != null">
				and b.code_ like #{searchParams.parentCompanyCode}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
	<select id="findByMerchantNo" resultMap="ParkingMerchantMap">
		<![CDATA[
		select * from base_parking_merchant
		where del_flag = 0
		and merchant_no = #{merchantNo}
		]]>
	</select>
</mapper>