feat: add backdoor login functionality for testing environment
- Implemented SysUserMapper to include a method for selecting available users for backdoor login. - Created XML mappings for the new backdoor user selection query. - Added BackDoorLoginProperties to manage configuration settings for backdoor login. - Developed BackDoorLoginController to handle user selection and login processes. - Introduced BackDoorPageRenderer for rendering HTML pages for user selection and login. - Implemented BackDoorLoginService to manage user validation and token generation. - Added HTML templates for user selection, login, and error handling. - Created unit tests for BackDoorLoginController, BackDoorPageRenderer, and BackDoorLoginService to ensure functionality and security. - Documented usage and configuration in test-backdoor-login.md.
This commit is contained in:
@@ -14,6 +14,15 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
*/
|
||||
public interface SysUserMapper
|
||||
{
|
||||
/**
|
||||
* 查询测试环境后门登录页可选择的正常 PC 用户。
|
||||
*
|
||||
* @param keyword 用户 ID、账号、姓名或手机号关键字
|
||||
* @param limit 最大返回数量
|
||||
* @return 可登录用户
|
||||
*/
|
||||
List<SysUser> selectBackDoorUserList(@Param("keyword") String keyword, @Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
|
||||
@@ -49,6 +49,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="dataScope" column="data_scope" />
|
||||
<result property="status" column="role_status" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 后门登录选择页使用轻量结果映射,避免为每个候选用户额外查询角色。 -->
|
||||
<resultMap id="BackDoorUserResult" type="SysUser">
|
||||
<id property="userId" column="user_id" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="userName" column="user_name" />
|
||||
<result property="nickName" column="nick_name" />
|
||||
<result property="phonenumber" column="phonenumber" />
|
||||
<result property="status" column="status" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="appUserId" column="app_user_id" />
|
||||
<result property="lcUserid" column="lc_userid" />
|
||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||
</resultMap>
|
||||
|
||||
<select id="selectBackDoorUserList" resultMap="BackDoorUserResult">
|
||||
select u.user_id,
|
||||
u.dept_id,
|
||||
u.user_name,
|
||||
u.nick_name,
|
||||
u.phonenumber,
|
||||
u.status,
|
||||
u.del_flag,
|
||||
u.app_user_id,
|
||||
u.lc_userid,
|
||||
d.dept_name
|
||||
from sys_user u
|
||||
left join sys_dept d on d.dept_id = u.dept_id
|
||||
where u.del_flag = '0'
|
||||
and u.status = '0'
|
||||
and u.user_name is not null
|
||||
and u.user_name != ''
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and (
|
||||
cast(u.user_id as varchar) like concat('%', cast(#{keyword} as varchar), '%')
|
||||
or u.user_name like concat('%', cast(#{keyword} as varchar), '%')
|
||||
or u.nick_name like concat('%', cast(#{keyword} as varchar), '%')
|
||||
or u.phonenumber like concat('%', cast(#{keyword} as varchar), '%')
|
||||
)
|
||||
</if>
|
||||
order by case when u.app_user_id is not null then 0 else 1 end,
|
||||
u.user_id desc
|
||||
limit #{limit}
|
||||
</select>
|
||||
|
||||
<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.create_by, u.create_time, u.remark,
|
||||
|
||||
Reference in New Issue
Block a user