<?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.tangguo.mapper.BbsUserPointsMapper">
    
    <select id="selectBbsUserPointsList" resultType="com.tangguo.domain.BbsUserPoints">
        SELECT
            p.id,
            IFNULL(p.accumulated_points, 0) AS accumulated_points,
            IFNULL(p.current_points, 0) AS current_points,
            uv.user_name,
            uv.nike_name,
            uv.dept_name
        FROM
            qwmh_sys_user_view uv
        LEFT JOIN
            bbs_user_points p ON p.user_name = uv.user_name
        <where>
            <if test="points.nikeName != null and points.nikeName != ''">
                uv.nike_name LIKE CONCAT('%', #{points.nikeName}, '%')
            </if>
            <if test="points.userName != null and points.userName != ''">
                AND uv.user_name LIKE CONCAT('%', #{points.userName}, '%')
            </if>
            <if test="points.startPoints != null">
                AND p.current_points >= #{points.startPoints}
            </if>
            <if test="points.endPoints != null">
                AND p.current_points &lt;= #{points.endPoints}
            </if>
        </where>
        ORDER BY
            p.accumulated_points DESC
    </select>
    
</mapper>
