<?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">

<mapper namespace="io.renren.modules.app.dao.XqxxDao">

	<!-- 可根据自己的需求，是否要使用 -->
	<resultMap type="io.renren.modules.app.entity.XqxxEntity" id="xqxxMap">
		<result property="xqbm" column="xqbm" />
		<result property="xqmc" column="xqmc" />
		<result property="dz" column="dz" />
		<result property="gzdbm" column="gzdbm" />
		<result property="jd" column="jd" />
		<result property="wd" column="wd" />
	</resultMap>

	<!-- GIS查询小区所有信息 -->
	<select id="queryGisZs" resultType="io.renren.modules.app.entity.XqxxEntity">
		select * from xqxx where jd IS NOT NULL AND wd IS NOT NULL 
	</select>

	<select id="queryByPage" parameterType="io.renren.modules.app.entity.XqxxEntity2"
		resultType="io.renren.modules.app.entity.XqxxEntity2">

		select xqxx.xqbm,
		xqxx.xqmc,
		xqxx.dz,
		xqxx.gzdbm,
		xqxx.jd,
		xqxx.wd,
		(select count(*) from xm where xm.xqbm = xqxx.xqbm) xqcon from xqxx where 1=1

		<if test=" xqbm!=null and xqbm!='' ">
			and xqbm like CONCAT(#{xqbm},"%")
		</if>
		<if test=" xqmc!=null and xqmc!='' ">
			and xqmc like CONCAT(#{xqmc},"%")
		</if>
		<if test=" dz!=null and dz!='' ">
			and dz like CONCAT(#{dz},"%")
		</if>
		<if test=" gzdbm!=null and gzdbm!='' ">
			and gzdbm like CONCAT(#{gzdbm},"%")
		</if>
		order by xqbm desc
	</select>

	<select id="queryxqbm" resultType="string">
		SELECT xqbm FROM xqxx WHERE
		LENGTH(xqbm)>=8 ORDER BY xqbm DESC LIMIT 1
	</select>


</mapper>