<?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.ParkingMerchantBinderDAO">
	<resultMap id="ParkingMerchantBinderMap" type="com.jpsoft.shinestar.modules.base.entity.ParkingMerchantBinder">
		<id property="id" column="id_" />
			<result property="name" column="name_" />
			<result property="nickName" column="nick_name" />
			<result property="picUrl" column="pic_url" />
			<result property="openId" column="open_id" />
			<result property="phone" column="phone_" />
			<result property="parkMerchantId" column="park_merchant_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" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ParkingMerchantBinder">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_parking_merchant_binder
	    (id_,name_,nick_name,pic_url,open_id,phone_,park_merchant_id,del_flag,create_by,create_time,update_by,update_time)
		values
		(
#{id,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR}
,#{nickName,jdbcType=VARCHAR}
,#{picUrl,jdbcType=VARCHAR}
,#{openId,jdbcType=VARCHAR}
,#{phone,jdbcType=VARCHAR}
,#{parkMerchantId,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_binder where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ParkingMerchantBinder">
		update base_parking_merchant_binder
		<set>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
				<if test="nickName!=null">
		nick_name=#{nickName,jdbcType=VARCHAR},
		</if>
				<if test="picUrl!=null">
		pic_url=#{picUrl,jdbcType=VARCHAR},
		</if>
				<if test="openId!=null">
		open_id=#{openId,jdbcType=VARCHAR},
		</if>
				<if test="phone!=null">
		phone_=#{phone,jdbcType=VARCHAR},
		</if>
				<if test="parkMerchantId!=null">
		park_merchant_id=#{parkMerchantId,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="ParkingMerchantBinderMap">
		select
id_,name_,nick_name,pic_url,open_id,phone_,park_merchant_id,del_flag,create_by,create_time,update_by,update_time		from base_parking_merchant_binder where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_parking_merchant_binder where id_=#{0}
	</select>
	<select id="list" resultMap="ParkingMerchantBinderMap">
		select * from base_parking_merchant_binder
	</select>
	<select id="search" parameterType="hashmap" resultMap="ParkingMerchantBinderMap">
		<![CDATA[
			select a.* from base_parking_merchant_binder a
		]]>
		<where>
			a.del_flag = 0
			<if test="searchParams.id != null">
				and a.ID_ like #{searchParams.id}
			</if>
			<if test="searchParams.name != null">
				and a.name_ like #{searchParams.name}
			</if>
			<if test="searchParams.nickName != null">
				and a.nick_name like #{searchParams.nickName}
			</if>
			<if test="searchParams.parkMerchantId != null">
				and a.park_merchant_id like #{searchParams.parkMerchantId}
			</if>
			<if test="searchParams.phone != null">
				and a.phone_ like #{searchParams.phone}
			</if>

		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

	<select id="findByOpenIdAndMerchantId" resultMap="ParkingMerchantBinderMap">
		<![CDATA[
		select * from base_parking_merchant_binder
		where del_flag = 0
		and open_id = #{openid}
		and park_merchant_id = #{merchantId}
		limit 1
		]]>
	</select>
</mapper>