<?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="com.nantian.cloud.jljc.mapper.EnergyLevelMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.EnergyLevel">
        <id column="id" property="id" />
        <result column="level" property="level" />
        <result column="lower_limit" property="lowerLimit" />
        <result column="upper_limit" property="upperLimit" />
        <result column="userid" property="userid"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, level, lower_limit, upper_limit, userid, update_time, del_flag, dept_id
    </sql>

    <select id="getPageScope" resultType="com.nantian.cloud.jljc.entity.EnergyLevel">
        select <include refid="Base_Column_List"></include>
        from energy_level
        <trim prefix="where" prefixOverrides="and">
            <if test="query.level != null and query.level != ''">
                and level like concat("%",#{query.level},"%")
            </if>
            <if test="query.lowerLimit != null and query.lowerLimit != ''">
                and lower_limit >=  #{query.lowerLimit}
            </if>
            <if test="query.upperLimit != null and query.upperLimit != ''">
                and #{query.upperLimit} >=  upper_limit
            </if>
            <if test="query.delFlag != null and query.delFlag != ''">
                and del_flag = #{query.delFlag}
            </if>
        </trim>
    </select>

</mapper>
