<?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.ParkingChannelDAO">
	<resultMap id="ParkingChannelMap" type="com.jpsoft.shinestar.modules.base.entity.ParkingChannel">
		<id property="id" column="id_" />
			<result property="channelId" column="channel_id" />
			<result property="channelName" column="channel_name" />
			<result property="parkId" column="park_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.ParkingChannel">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_parking_channel
	    (id_,channel_id,channel_name,park_id,del_flag,create_by,create_time,update_by,update_time)
		values
		(
#{id,jdbcType=VARCHAR}
,#{channelId,jdbcType=VARCHAR}
,#{channelName,jdbcType=VARCHAR}
,#{parkId,jdbcType= NUMERIC }
,#{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_channel where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ParkingChannel">
		update base_parking_channel
		<set>
				<if test="channelId!=null">
		channel_id=#{channelId,jdbcType=VARCHAR},
		</if>
				<if test="channelName!=null">
		channel_name=#{channelName,jdbcType=VARCHAR},
		</if>
				<if test="parkId!=null">
		park_id=#{parkId,jdbcType= NUMERIC },
		</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="ParkingChannelMap">
		select * from base_parking_channel where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_parking_channel where id_=#{0}
	</select>
	<select id="list" resultMap="ParkingChannelMap">
		select * from base_parking_channel
	</select>
	<select id="search" parameterType="hashmap" resultMap="ParkingChannelMap">
		<![CDATA[
			select * from base_parking_channel
		]]>
		<where>
			<if test="searchParams.id != null">
				and ID_ like #{searchParams.id}
			</if>
			<if test="searchParams.parkId != null">
				and park_id = #{searchParams.parkId}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

	<select id="findByParkId" resultMap="ParkingChannelMap">
		select * from base_parking_channel where del_flag = 0 and park_id = #{parkId}
	</select>

	<select id="findByChannelId" resultMap="ParkingChannelMap">
		select * from base_parking_channel where del_flag = 0 and channel_id = #{channelId}
		limit 1
	</select>

	<delete id="deleteNotExist" parameterType="arraylist">
		delete from base_parking_channel
		where channel_id
		<foreach item="list" collection="list" open="not in  (" separator="," close=")">
			#{list.channelId}
		</foreach>
	</delete>

</mapper>