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

    <!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="io.renren.modules.app.entity.LlbEntity" id="llbMap">
                    <result property="id" column="id"/>
                    <result property="bm" column="bm"/>
                    <result property="mc" column="mc"/>
                    <result property="ll" column="ll"/>
                    <result property="sfty" column="sfty"/>
                    <result property="begdate" column="begdate"/>
                    <result property="enddate" column="enddate"/>
                    <result property="gzdbm" column="gzdbm"/>
                    <result property="lltype" column="lltype"/>
            </resultMap>

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

        select id,mc,ll,(case
		sfty when '1' then '使用中' when '0' then '已停用' else '' END) sfty,begdate,enddate from llb 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=" ll!=null and ll!='' ">
                and ll like CONCAT(#{ll},"%")
            </if>
                    <if test=" sfty!=null and sfty!='' ">
                and sfty like CONCAT(#{sfty},"%")
            </if>
                    <if test=" begdate!=null and begdate!='' ">
                and begdate like CONCAT(#{begdate},"%")
            </if>
                    <if test=" enddate!=null and enddate!='' ">
                and enddate like CONCAT(#{enddate},"%")
            </if>
                    <if test=" gzdbm!=null and gzdbm!='' ">
                and gzdbm like CONCAT(#{gzdbm},"%")
            </if>
                    <if test=" lltype!=null and lltype!='' ">
                and lltype like CONCAT(#{lltype},"%")
            </if>
        order by bm desc
    </select>
    
    <select id="querybm"  resultType="string">
    SELECT bm FROM llb WHERE LENGTH(bm)>=7 ORDER BY bm  DESC LIMIT 1
    </select>


</mapper>