mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
refactor(SysUserMapper): 优化用户查询方法命名和SQL逻辑
- 将selectVoListByScope重命名为getUserVoListByScope以保持命名一致性 - 优化SQL查询条件顺序,将tenant_id条件前置 - 在用户列表查询中增加phone模糊查询条件 - 调整tenant_id IS NULL条件位置以提高查询效率
This commit is contained in:
1 parent
f7c1dc402a
commit
31cae49a17
3 files changed
+40
-36
No files matched your search
+29
-32
@@ -41,40 +41,37 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface SysUserMapper extends PigxBaseMapper<SysUser> {
|
||||
|
||||
/**
|
||||
* 通过用户DTO查询用户信息(包含角色信息)
|
||||
*
|
||||
* @param userDTO 用户查询DTO
|
||||
* @return 包含角色信息的用户VO
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
UserVO getUserVo(@Param("query") UserDTO userDTO);
|
||||
/**
|
||||
* 通过用户DTO查询用户信息(包含角色信息)
|
||||
* @param userDTO 用户查询DTO
|
||||
* @return 包含角色信息的用户VO
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
UserVO getUserVo(@Param("query") UserDTO userDTO);
|
||||
|
||||
/**
|
||||
* 分页查询用户信息(含角色)
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param userDTO 用户查询参数
|
||||
* @param dataScope 数据权限范围
|
||||
* @return 分页用户信息列表
|
||||
*/
|
||||
IPage<UserVO> getUserVosPage(Page page, @Param("query") UserDTO userDTO, DataScope dataScope);
|
||||
/**
|
||||
* 分页查询用户信息(含角色)
|
||||
* @param page 分页对象
|
||||
* @param userDTO 用户查询参数
|
||||
* @param dataScope 数据权限范围
|
||||
* @return 分页用户信息列表
|
||||
*/
|
||||
IPage<UserVO> getUserVosPage(Page page, @Param("query") UserDTO userDTO, DataScope dataScope);
|
||||
|
||||
/**
|
||||
* 通过ID查询用户信息
|
||||
* @param id 用户ID
|
||||
* @return 用户信息VO对象
|
||||
*/
|
||||
UserVO getUserVoById(Long id);
|
||||
/**
|
||||
* 通过ID查询用户信息
|
||||
* @param id 用户ID
|
||||
* @return 用户信息VO对象
|
||||
*/
|
||||
UserVO getUserVoById(Long id);
|
||||
|
||||
/**
|
||||
* 根据数据权限查询用户列表
|
||||
*
|
||||
* @param userDTO 查询条件
|
||||
* @param ids 用户ID数组
|
||||
* @param dataScope 数据权限声明
|
||||
* @return 用户VO列表
|
||||
*/
|
||||
List<UserVO> selectVoListByScope(@Param("query") UserDTO userDTO, @Param("ids") Long[] ids, DataScope dataScope);
|
||||
/**
|
||||
* 根据数据权限查询用户列表
|
||||
* @param userDTO 查询条件
|
||||
* @param ids 用户ID数组
|
||||
* @param dataScope 数据权限声明
|
||||
* @return 用户VO列表
|
||||
*/
|
||||
List<UserVO> getUserVoListByScope(@Param("query") UserDTO userDTO, @Param("ids") Long[] ids, DataScope dataScope);
|
||||
|
||||
}
|
||||
+1
-1
@@ -348,7 +348,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public List<UserExcelVO> listUser(UserDTO userDTO, Long[] ids) {
|
||||
// 根据数据权限查询全部的用户信息
|
||||
userDTO.setTenantId(SecurityUtils.getUser().getTenantId());
|
||||
List<UserVO> voList = baseMapper.selectVoListByScope(userDTO, ids, DataScope.of());
|
||||
List<UserVO> voList = baseMapper.getUserVoListByScope(userDTO, ids, DataScope.of());
|
||||
return voList.stream().map(userVO -> {
|
||||
UserExcelVO excelVO = new UserExcelVO();
|
||||
BeanUtils.copyProperties(userVO, excelVO);
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
sys_user u
|
||||
LEFT JOIN sys_user_dept ud ON u.user_id = ud.user_id
|
||||
WHERE
|
||||
ud.tenant_id = #{query.tenantId} OR ud.tenant_id IS NULL
|
||||
ud.tenant_id = #{query.tenantId}
|
||||
AND u.del_flag = '0'
|
||||
<!-- 用户名模糊查询 -->
|
||||
<if test="query.username != null and query.username != ''">
|
||||
@@ -130,11 +130,12 @@
|
||||
<bind name="phoneLike" value="'%' + query.phone + '%'"/>
|
||||
AND u.phone LIKE #{phoneLike}
|
||||
</if>
|
||||
OR ud.tenant_id IS NULL
|
||||
ORDER BY
|
||||
u.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="selectVoListByScope" resultMap="baseResultMap">
|
||||
<select id="getUserVoListByScope" resultMap="baseResultMap">
|
||||
SELECT
|
||||
<include refid="userColumns"/>,
|
||||
ud.dept_id
|
||||
@@ -142,7 +143,7 @@
|
||||
sys_user u
|
||||
LEFT JOIN sys_user_dept ud ON u.user_id = ud.user_id
|
||||
WHERE
|
||||
ud.tenant_id = #{query.tenantId} OR ud.tenant_id IS NULL
|
||||
ud.tenant_id = #{query.tenantId}
|
||||
AND u.del_flag = '0'
|
||||
<!-- 用户名模糊查询 -->
|
||||
<if test="query.username != null and query.username != ''">
|
||||
@@ -153,6 +154,11 @@
|
||||
<if test="query.deptId != null and query.deptId != ''">
|
||||
AND ud.dept_id = #{query.deptId}
|
||||
</if>
|
||||
<!-- 手机号模糊查询 -->
|
||||
<if test="query.phone != null and query.phone != ''">
|
||||
<bind name="phoneLike" value="'%' + query.phone + '%'"/>
|
||||
AND u.phone LIKE #{phoneLike}
|
||||
</if>
|
||||
<!-- 用户ID范围查询 -->
|
||||
<if test="ids != null and ids.length > 0">
|
||||
AND u.user_id IN
|
||||
@@ -160,6 +166,7 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
OR ud.tenant_id IS NULL
|
||||
ORDER BY
|
||||
u.create_time DESC
|
||||
</select>
|
||||
|
||||
Reference in new issue
Block a user