<?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.OwnerInfoDAO">
	<resultMap id="OwnerInfoMap" type="OwnerInfo">
		<id property="id" column="id_" />
			<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" />
			<result property="name" column="name_" />
			<result property="tel" column="tel_" />
			<result property="park" column="park_" />
			<result property="building" column="building" />
			<result property="area" column="area_" />
			<result property="checkinTime" column="checkin_time" />
			<result property="propertyCosts" column="property_costs" />
			<result property="cardNo" column="card_no" />
			<result property="authority" column="authority_" />
			<result property="carNo" column="car_no" />
			<result property="isAccessControl" column="is_access_control" />
			<result property="isThePublic" column="is_the_public" />
			<result property="roomId" column="room_id" />
			</resultMap>
	<insert id="insert" parameterType="OwnerInfo">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_owner_info
	    (id_,create_by,create_time,update_by,update_time,del_flag,name_,tel_,park_,building,area_,checkin_time,property_costs,card_no,authority_,car_no,is_access_control,is_the_public,room_id)
		values
		(
#{id,jdbcType=VARCHAR}
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{delFlag,jdbcType= NUMERIC }
,#{name,jdbcType=VARCHAR}
,#{tel,jdbcType=VARCHAR}
,#{park,jdbcType=VARCHAR}
,#{building,jdbcType=VARCHAR}
,#{area,jdbcType=VARCHAR}
,#{checkinTime,jdbcType= TIMESTAMP }
,#{propertyCosts,jdbcType= NUMERIC }
,#{cardNo,jdbcType=VARCHAR}
,#{authority,jdbcType=VARCHAR}
,#{carNo,jdbcType=VARCHAR}
,#{isAccessControl,jdbcType= NUMERIC }
,#{isThePublic,jdbcType= NUMERIC }
,#{roomId,jdbcType= VARCHAR }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_owner_info where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="OwnerInfo">
		update base_owner_info
		<set>
				<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>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
				<if test="tel!=null">
		tel_=#{tel,jdbcType=VARCHAR},
		</if>
				<if test="park!=null">
		park_=#{park,jdbcType=VARCHAR},
		</if>
				<if test="building!=null">
		building=#{building,jdbcType=VARCHAR},
		</if>
				<if test="area!=null">
		area_=#{area,jdbcType=VARCHAR},
		</if>
				<if test="checkinTime!=null">
		checkin_time=#{checkinTime,jdbcType= TIMESTAMP },
		</if>
				<if test="propertyCosts!=null">
		property_costs=#{propertyCosts,jdbcType= NUMERIC },
		</if>
				<if test="cardNo!=null">
		card_no=#{cardNo,jdbcType=VARCHAR},
		</if>
				<if test="authority!=null">
		authority_=#{authority,jdbcType=VARCHAR},
		</if>
				<if test="carNo!=null">
		car_no=#{carNo,jdbcType=VARCHAR},
		</if>
				<if test="isAccessControl!=null">
		is_access_control=#{isAccessControl,jdbcType= NUMERIC },
		</if>
				<if test="isThePublic!=null">
		is_the_public=#{isThePublic,jdbcType= NUMERIC },
		</if>
			<if test="roomId!=null">
				room_id=#{roomId,jdbcType= VARCHAR },
		</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="OwnerInfoMap">
		select * from base_owner_info where id_=#{0} and del_flag = 0
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_owner_info where id_=#{0} and del_flag = 0
	</select>
	<select id="list" resultMap="OwnerInfoMap">
		select * from base_owner_info where del_flag = 0
	</select>
	<select id="search" parameterType="hashmap" resultMap="OwnerInfoMap">
		<![CDATA[
			select * from base_owner_info
		]]>
		<where>
			del_flag = 0
			<if test="searchParams.id != null">
				and ID_ like #{searchParams.id}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

	<select id="findByTel" resultType="map">
		SELECT
		id_ as id,
		name_ as name,
		tel_ as tel,
		is_access_control as isAccessControl,
		is_the_public as isThePublic
		FROM
		base_owner_info
		WHERE
		del_flag = 0
		and tel_ = #{0}
	</select>
</mapper>