<?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.CanteenInfoDAO">
	<resultMap id="CanteenInfoMap" type="com.jpsoft.shinestar.modules.base.entity.CanteenInfo">
		<id property="id" column="id_" />
			<result property="name" column="name_" />
			<result property="address" column="address_" />
			<result property="lunchTime" column="lunch_time" />
			<result property="lunchFee" column="lunch_fee" />
			<result property="dinnerTime" column="dinner_time" />
			<result property="dinnerFee" column="dinner_fee" />
			<result property="midnightTime" column="midnight_time" />
			<result property="midnightFee" column="midnight_fee" />
			<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="delFlag" column="del_flag" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.CanteenInfo">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_canteen_info
	    (id_,name_,address_,lunch_time,lunch_fee,dinner_time,dinner_fee,midnight_time,midnight_fee,create_by,create_time,update_by,update_time,del_flag)
		values
		(
#{id,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR}
,#{address,jdbcType=VARCHAR}
,#{lunchTime,jdbcType=VARCHAR}
,#{lunchFee,jdbcType= NUMERIC }
,#{dinnerTime,jdbcType=VARCHAR}
,#{dinnerFee,jdbcType= NUMERIC }
,#{midnightTime,jdbcType=VARCHAR}
,#{midnightFee,jdbcType= NUMERIC }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{delFlag,jdbcType= NUMERIC }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_canteen_info where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="CanteenInfo">
		update base_canteen_info
		<set>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
				<if test="address!=null">
		address_=#{address,jdbcType=VARCHAR},
		</if>
				<if test="lunchTime!=null">
		lunch_time=#{lunchTime,jdbcType=VARCHAR},
		</if>
				<if test="lunchFee!=null">
		lunch_fee=#{lunchFee,jdbcType= NUMERIC },
		</if>
				<if test="dinnerTime!=null">
		dinner_time=#{dinnerTime,jdbcType=VARCHAR},
		</if>
				<if test="dinnerFee!=null">
		dinner_fee=#{dinnerFee,jdbcType= NUMERIC },
		</if>
				<if test="midnightTime!=null">
		midnight_time=#{midnightTime,jdbcType=VARCHAR},
		</if>
				<if test="midnightFee!=null">
		midnight_fee=#{midnightFee,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>
				<if test="delFlag!=null">
		del_flag=#{delFlag,jdbcType= NUMERIC },
		</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="CanteenInfoMap">
		select 
id_,name_,address_,lunch_time,lunch_fee,dinner_time,dinner_fee,midnight_time,midnight_fee,create_by,create_time,update_by,update_time,del_flag		from base_canteen_info where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_canteen_info where id_=#{0}
	</select>
	<select id="list" resultMap="CanteenInfoMap">
		select * from base_canteen_info
	</select>
	<select id="search" parameterType="hashmap" resultMap="CanteenInfoMap">
		<![CDATA[
			select * from base_canteen_info
		]]>
		<where>
			del_flag = false
			<if test="searchParams.name != null">
				and name_ like #{searchParams.name}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>
</mapper>