fix: 优化SQL
This commit is contained in:
parent
ebc2e3a22b
commit
3e01554ae5
@ -116,6 +116,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
Map<String, Object> queryConditions = new HashMap<>();
|
Map<String, Object> queryConditions = new HashMap<>();
|
||||||
queryConditions.put("excludeUid", uid);
|
queryConditions.put("excludeUid", uid);
|
||||||
queryConditions.put("currentLevel", currentLevel); // 添加当前用户的等级作为查询条件
|
queryConditions.put("currentLevel", currentLevel); // 添加当前用户的等级作为查询条件
|
||||||
|
System.out.println("==============================" +
|
||||||
|
queryConditions.toString() +
|
||||||
|
"============================");
|
||||||
List<UserInfo> userInfos;
|
List<UserInfo> userInfos;
|
||||||
log.info("要查询的用户类型是:{}", userListParam.getUserType());
|
log.info("要查询的用户类型是:{}", userListParam.getUserType());
|
||||||
if (Objects.equals(userListParam.getUserType(), "activate")) {
|
if (Objects.equals(userListParam.getUserType(), "activate")) {
|
||||||
|
@ -41,24 +41,40 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- getUserListAll 方法 -->
|
<!-- getUserListAll 方法 -->
|
||||||
|
<!-- <select id="getUserListAll" resultType="com.guaiguailang.harmony.domain.entity.UserInfo">-->
|
||||||
|
<!-- SELECT * FROM user_info-->
|
||||||
|
<!-- <where>-->
|
||||||
|
<!-- <if test="merchantCode != 'ALL'">-->
|
||||||
|
<!-- WHERE merchant_code = #{merchantCode}-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- <if test="queryConditions.excludeUid != null">-->
|
||||||
|
<!-- AND id != #{queryConditions.excludeUid}-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- <if test="queryConditions.currentLevel != null">-->
|
||||||
|
<!-- AND role_id IN (-->
|
||||||
|
<!-- SELECT role_id FROM system_role WHERE level >= #{queryConditions.currentLevel}-->
|
||||||
|
<!-- )-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- </where>-->
|
||||||
|
<!-- LIMIT #{limit},#{end}-->
|
||||||
|
<!-- </select>-->
|
||||||
<select id="getUserListAll" resultType="com.guaiguailang.harmony.domain.entity.UserInfo">
|
<select id="getUserListAll" resultType="com.guaiguailang.harmony.domain.entity.UserInfo">
|
||||||
SELECT * FROM user_info
|
SELECT * FROM user_info
|
||||||
<where>
|
<where>
|
||||||
<if test="merchantCode != 'ALL'">
|
<if test="merchantCode != 'ALL'">
|
||||||
WHERE merchant_code = #{merchantCode}
|
merchant_code = #{merchantCode}
|
||||||
</if>
|
</if>
|
||||||
<if test="queryConditions.excludeUid != null">
|
<if test="queryConditions.excludeUid != null">
|
||||||
AND id != #{queryConditions.excludeUid}
|
AND id != #{queryConditions.excludeUid}
|
||||||
</if>
|
</if>
|
||||||
<if test="queryConditions.currentLevel != null">
|
<if test="queryConditions.currentLevel != null">
|
||||||
AND role_id IN (
|
AND role_id IN (
|
||||||
SELECT role_id FROM system_role WHERE level >= #{queryConditions.currentLevel}
|
SELECT role_id FROM system_role WHERE level >= #{queryConditions.currentLevel}
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
LIMIT #{limit},#{end}
|
LIMIT #{limit}, #{end}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUserListNum" resultType="com.guaiguailang.harmony.domain.vo.UserListNum">
|
<select id="getUserListNum" resultType="com.guaiguailang.harmony.domain.vo.UserListNum">
|
||||||
SELECT
|
SELECT
|
||||||
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS userActivatedNum,
|
SUM(CASE WHEN status = 1 THEN 1 ELSE 0 END) AS userActivatedNum,
|
||||||
|
Loading…
Reference in New Issue
Block a user