From ed209eeb52e8d778ab2b3e8c86a3e63a924e53ec Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 26 十月 2025 19:03:26 +0800
Subject: [PATCH] fix:用户登录及车辆列表展示优化
---
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 49 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index 8c40c86..aabf8a1 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -48,7 +48,7 @@
</resultMap>
<sql id="selectUserVo">
- select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.oa_user_id, u.create_by, u.create_time, u.remark,
+ select u.user_id, u.dept_id, u.user_name,u.oa_user_id, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.oa_user_id, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@@ -65,7 +65,7 @@
AND u.user_id = #{userId}
</if>
<if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
+ AND u.nick_name like concat('%', #{userName}, '%')
</if>
<if test="status != null and status != ''">
AND u.status = #{status}
@@ -80,7 +80,44 @@
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
</if>
<if test="deptId != null and deptId != 0">
- AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
+ <![CDATA[
+ AND u.dept_id IN (
+ -- 鏌ヨ鐢ㄦ埛鎵�灞炲垎鍏徃鍙婂叾鎵�鏈夊瓙閮ㄩ棬
+ SELECT t.dept_id FROM sys_dept t
+ WHERE t.del_flag = '0' AND (
+ -- 鎯呭喌1锛氫紶鍏ョ殑閮ㄩ棬灏辨槸鍒嗗叕鍙�(parent_id=100)
+ (t.dept_id = ]]>#{deptId}<![CDATA[ AND EXISTS (
+ SELECT 1 FROM sys_dept d WHERE d.dept_id = ]]>#{deptId}<![CDATA[ AND d.parent_id = 100
+ ))
+ OR
+ -- 鏌ヨ璇ュ垎鍏徃鐨勬墍鏈夊瓙閮ㄩ棬
+ (find_in_set(
+ (SELECT d.dept_id FROM sys_dept d WHERE d.dept_id = ]]>#{deptId}<![CDATA[ AND d.parent_id = 100),
+ t.ancestors
+ ) > 0)
+ OR
+ -- 鎯呭喌2锛氫紶鍏ョ殑鏄瓙閮ㄩ棬锛屾壘鍒板叾鎵�灞炲垎鍏徃
+ (t.dept_id IN (
+ SELECT branch.dept_id FROM sys_dept branch
+ WHERE branch.parent_id = 100
+ AND find_in_set(branch.dept_id, (
+ SELECT sub.ancestors FROM sys_dept sub WHERE sub.dept_id = ]]>#{deptId}<![CDATA[
+ )) > 0
+ ))
+ OR
+ -- 鏌ヨ璇ュ垎鍏徃鐨勬墍鏈夊瓙閮ㄩ棬
+ (find_in_set(
+ (SELECT branch.dept_id FROM sys_dept branch
+ WHERE branch.parent_id = 100
+ AND find_in_set(branch.dept_id, (
+ SELECT sub.ancestors FROM sys_dept sub WHERE sub.dept_id = ]]>#{deptId}<![CDATA[
+ )) > 0
+ ),
+ t.ancestors
+ ) > 0)
+ )
+ )
+ ]]>
</if>
<!-- 鏁版嵁鑼冨洿杩囨护 -->
${params.dataScope}
@@ -125,7 +162,11 @@
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
</select>
-
+ <select id="selectUserByPhonenumber" parameterType="String" resultMap="SysUserResult">
+ <include refid="selectUserVo"/>
+ where u.phonenumber = #{phonenumber} and u.del_flag = '0'
+ </select>
+
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_id = #{userId}
--
Gitblit v1.9.1