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

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="io.renren.modules.app.entity.JkbzEntity" id="jkbzMap">
                    <result property="id" column="id"/>
                    <result property="bm" column="bm"/>
                    <result property="mc" column="mc"/>
                    <result property="ftbz" column="ftbz"/>
                    <result property="jsbz" column="jsbz"/>
                    <result property="gzdbm" column="gzdbm"/>
                    <result property="grjjl" column="grjjl"/>
                    <result property="fwyt" column="fwyt"/>
                    <result property="dwjjl" column="dwjjl"/>
            </resultMap>

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

        select id,mc,dwjjl,grjjl,(case
		jsbz when '1' then '按金额' when '0' then '按面积' else '' END)
		jsbz,(case
		fwyt when '1' then '非住宅' when '0' then '住宅' else '' END) fwyt from jkbz where 1=1

                    <if test=" id!=null and id!='' ">
                and id like CONCAT(#{id},"%")
            </if>
                    <if test=" bm!=null and bm!='' ">
                and bm like CONCAT(#{bm},"%")
            </if>
                    <if test=" mc!=null and mc!='' ">
                and mc like CONCAT(#{mc},"%")
            </if>
                    <if test=" ftbz!=null and ftbz!='' ">
                and ftbz like CONCAT(#{ftbz},"%")
            </if>
                    <if test=" jsbz!=null and jsbz!='' ">
                and jsbz like CONCAT(#{jsbz},"%")
            </if>
                    <if test=" gzdbm!=null and gzdbm!='' ">
                and gzdbm like CONCAT(#{gzdbm},"%")
            </if>
                    <if test=" grjjl!=null and grjjl!='' ">
                and grjjl like CONCAT(#{grjjl},"%")
            </if>
                    <if test=" fwyt!=null and fwyt!='' ">
                and fwyt like CONCAT(#{fwyt},"%")
            </if>
            <if test=" dwjjl!=null and dwjjl!='' ">
                and dwjjl like CONCAT(#{dwjjl},"%")
            </if>
        order by bm desc
    </select>
    
    <select id="querybm"  resultType="string">
    SELECT bm FROM jkbz WHERE LENGTH(bm)>=8 ORDER BY bm  DESC LIMIT 1
    </select>


</mapper>