43 lines
1.6 KiB
XML
43 lines
1.6 KiB
XML
|
|
<?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="org.xyzh.usercenter.mapper.UserPointsMapper">
|
||
|
|
|
||
|
|
<!-- 基础结果映射 -->
|
||
|
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserPoints">
|
||
|
|
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||
|
|
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||
|
|
<result column="total_points" property="totalPoints" jdbcType="INTEGER"/>
|
||
|
|
<result column="current_points" property="currentPoints" jdbcType="INTEGER"/>
|
||
|
|
<result column="level" property="level" jdbcType="INTEGER"/>
|
||
|
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||
|
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<!-- 基础字段 -->
|
||
|
|
<sql id="Base_Column_List">
|
||
|
|
id, user_id, total_points, current_points, level, create_time, update_time
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<!-- 通用条件 -->
|
||
|
|
<sql id="Where_Clause">
|
||
|
|
<where>
|
||
|
|
<if test="userID != null and userID != ''">
|
||
|
|
AND user_id = #{userID}
|
||
|
|
</if>
|
||
|
|
<if test="level != null">
|
||
|
|
AND level = #{level}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</sql>
|
||
|
|
|
||
|
|
<!-- selectUserPoints -->
|
||
|
|
<select id="selectUserPoints" resultMap="BaseResultMap">
|
||
|
|
SELECT
|
||
|
|
<include refid="Base_Column_List"/>
|
||
|
|
FROM tb_user_points
|
||
|
|
<include refid="Where_Clause"/>
|
||
|
|
ORDER BY level DESC, current_points DESC
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|