<?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.ReturnInfoDAO">
	<resultMap id="ReturnInfoMap" type="com.jpsoft.shinestar.modules.base.entity.ReturnInfo">
		<id property="id" column="id_" />
			<result property="name" column="name_" />
			<result property="openId" column="open_id" />
			<result property="idCard" column="id_card" />
			<result property="phone" column="phone_" />
			<result property="liveRegionId" column="live_region_id" />
			<result property="liveDetailAddress" column="live_detail_address" />
			<result property="originId" column="origin_id" />
			<result property="originDetailAddress" column="origin_detail_address" />
			<result property="avenuePlace" column="avenue_place" />
			<result property="vehicle" column="vehicle_" />
			<result property="arriveTime" column="arrive_time" />
			<result property="haveCheck" column="have_check" />
			<result property="remark" column="remark_" />
			<result property="checkImageUrl" column="check_image_url" />
			<result property="travelImageUrl" column="travel_image_url" />
			<result property="healthCodeUrl" column="health_code_url" />
			<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="type" column="type_"/>
			<result property="enableUpdate" column="enable_update"/>
			<result property="newFlag" column="new_flag"/>
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.base.entity.ReturnInfo">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into base_return_info
	    (id_,name_,open_id,id_card,phone_,live_region_id,live_detail_address,origin_id,origin_detail_address,avenue_place,vehicle_,arrive_time,have_check,remark_,check_image_url,travel_image_url,health_code_url,del_flag,create_by,create_time,update_by,update_time,type_,enable_update,new_flag)
		values
		(
#{id,jdbcType=VARCHAR}
,#{name,jdbcType=VARCHAR}
,#{openId,jdbcType=VARCHAR}
,#{idCard,jdbcType=VARCHAR}
,#{phone,jdbcType=VARCHAR}
,#{liveRegionId,jdbcType=VARCHAR}
,#{liveDetailAddress,jdbcType=VARCHAR}
,#{originId,jdbcType=VARCHAR}
,#{originDetailAddress,jdbcType=VARCHAR}
,#{avenuePlace,jdbcType=VARCHAR}
,#{vehicle,jdbcType=VARCHAR}
,#{arriveTime,jdbcType= TIMESTAMP }
,#{haveCheck,jdbcType= NUMERIC }
,#{remark,jdbcType=VARCHAR}
,#{checkImageUrl,jdbcType=VARCHAR}
,#{travelImageUrl,jdbcType=VARCHAR}
,#{healthCodeUrl,jdbcType=VARCHAR}
,#{delFlag,jdbcType= NUMERIC }
,#{createBy,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateBy,jdbcType=VARCHAR}
,#{updateTime,jdbcType= TIMESTAMP }
,#{type,jdbcType=VARCHAR}
,#{enableUpdate,jdbcType=NUMERIC}
,#{newFlag,jdbcType=NUMERIC}
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from base_return_info where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.base.entity.ReturnInfo">
		update base_return_info
		<set>
				<if test="name!=null">
		name_=#{name,jdbcType=VARCHAR},
		</if>
				<if test="openId!=null">
		open_id=#{openId,jdbcType=VARCHAR},
		</if>
				<if test="idCard!=null">
		id_card=#{idCard,jdbcType=VARCHAR},
		</if>
				<if test="phone!=null">
		phone_=#{phone,jdbcType=VARCHAR},
		</if>
				<if test="liveRegionId!=null">
		live_region_id=#{liveRegionId,jdbcType=VARCHAR},
		</if>
				<if test="liveDetailAddress!=null">
		live_detail_address=#{liveDetailAddress,jdbcType=VARCHAR},
		</if>
				<if test="originId!=null">
		origin_id=#{originId,jdbcType=VARCHAR},
		</if>
				<if test="originDetailAddress!=null">
		origin_detail_address=#{originDetailAddress,jdbcType=VARCHAR},
		</if>
				<if test="avenuePlace!=null">
		avenue_place=#{avenuePlace,jdbcType=VARCHAR},
		</if>
				<if test="vehicle!=null">
		vehicle_=#{vehicle,jdbcType=VARCHAR},
		</if>
				<if test="arriveTime!=null">
		arrive_time=#{arriveTime,jdbcType= TIMESTAMP },
		</if>
				<if test="haveCheck!=null">
		have_check=#{haveCheck,jdbcType= NUMERIC },
		</if>
				<if test="remark!=null">
		remark_=#{remark,jdbcType=VARCHAR},
		</if>
				<if test="checkImageUrl!=null">
		check_image_url=#{checkImageUrl,jdbcType=VARCHAR},
		</if>
				<if test="travelImageUrl!=null">
		travel_image_url=#{travelImageUrl,jdbcType=VARCHAR},
		</if>
				<if test="healthCodeUrl!=null">
		health_code_url=#{healthCodeUrl,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>
			<if test="type!=null">
				type_=#{type,jdbcType=VARCHAR},
			</if>
			<if test="enableUpdate!=null">
				enable_update=#{enableUpdate,jdbcType= NUMERIC },
			</if>
			<if test="newFlag!=null">
				new_flag=#{newFlag,jdbcType= NUMERIC },
			</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="ReturnInfoMap">
		select *	from base_return_info where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from base_return_info where id_=#{0}
	</select>
	<select id="list" resultMap="ReturnInfoMap">
		select * from base_return_info
	</select>
	<select id="search" parameterType="hashmap" resultMap="ReturnInfoMap">
		<![CDATA[
			select * from base_return_info
		]]>
		<where>
			and del_flag = 0
			<if test="searchParams.id != null">
				and ID_ like #{searchParams.id}
			</if>
			<if test="searchParams.liveRegionId != null">
				and live_region_id = #{searchParams.liveRegionId}
			</if>
			<if test="searchParams.enableUpdate != null">
				and enable_update = #{searchParams.enableUpdate}
			</if>
			<if test="searchParams.phone != null">
				and phone_ like #{searchParams.phone}
			</if>
			<if test="searchParams.enableUpdate != null">
				and enable_update = #{searchParams.enableUpdate}
			</if>
			<if test="searchParams.name != null">
				and name_ like #{searchParams.name}
			</if>
			<if test="searchParams.idCard != null">
				and id_card = #{searchParams.idCard}
			</if>

			<if test="searchParams.liveRegionIdList != null">
				<foreach item="companyInfo" collection="searchParams.liveRegionIdList" open="and live_region_id in(" separator="," close=")">
					#{companyInfo.regionId}
				</foreach>
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

	<select id="findByOpenId" resultMap="ReturnInfoMap">
		<![CDATA[

		select * from base_return_info
		where del_flag = 0
		and open_id = #{openId}
        limit 1
		]]>
	</select>

	<select id="findByIdCardOrPhone" resultMap="ReturnInfoMap">
		<![CDATA[

		select * from base_return_info
		where del_flag = 0

		]]>
		<if test="idCard != null">
			and id_card = #{idCard}
		</if>
		<if test="phone != null">
			and phone_ = #{phone}
		</if>
		limit 1
	</select>
</mapper>