@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 新增用户返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:01 (新增用户) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 删除用户返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:02 (删除用户) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 删除用户返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:03 (删除用户) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 修改用户密码返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:04 (修改用户密码) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 修改用户状态返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:05 (修改用户状态) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 根据ID查询用户信息返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:06 (根据ID查询用户信息) | |||
* | |||
* @author wanjing |
@@ -2,7 +2,7 @@ package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 根据部门ID查询用户列表返回码 | |||
* 模块代码:10(部门管理) | |||
* 模块代码:10(用户管理) | |||
* 接口代码:07 (据部门ID查询用户列表) | |||
* | |||
* @author wanjing |
@@ -0,0 +1,47 @@ | |||
package com.tuoheng.admin.enums.code.user; | |||
/** | |||
* 查询用户分页列表返回码 | |||
* 模块代码:10(用户管理) | |||
* 接口代码:08 (询用户分页列表) | |||
* | |||
* @author wanjing | |||
* @team tuoheng | |||
* @date 2022-12-08 | |||
*/ | |||
public enum QueryUserPageListCodeEnum { | |||
ORDINARY_USERS_NO_PERMISSION(1100801, "普通用户没有查询权限"); | |||
/** | |||
* 错误码 | |||
*/ | |||
private int code; | |||
/** | |||
* 错误信息 | |||
*/ | |||
private String msg; | |||
QueryUserPageListCodeEnum(int code, String msg){ | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
} |
@@ -3,6 +3,8 @@ package com.tuoheng.admin.request.user; | |||
import com.tuoheng.common.core.common.BaseQuery; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* 用户查询条件 | |||
*/ | |||
@@ -29,4 +31,9 @@ public class QueryUserPageListRequest extends BaseQuery { | |||
*/ | |||
private Integer roleId; | |||
/** | |||
* 部门及子部门Id列表 | |||
*/ | |||
private List<String> deptIdList; | |||
} |
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.tuoheng.admin.conver.UserConverMapper; | |||
import com.tuoheng.admin.entity.*; | |||
import com.tuoheng.admin.enums.RoleEnum; | |||
import com.tuoheng.admin.enums.code.user.QueryUserPageListCodeEnum; | |||
import com.tuoheng.admin.mapper.DeptMapper; | |||
import com.tuoheng.admin.mapper.RoleMapper; | |||
import com.tuoheng.admin.mapper.UserMapper; | |||
@@ -50,15 +52,19 @@ public class QueryUserPageListService { | |||
*/ | |||
public JsonResult getPageList(QueryUserPageListRequest request) { | |||
log.info("进入查询用户分页列表业务"); | |||
JsonResult result = this.check(request); | |||
User user = CurrentUserUtil.getUserInfo(); | |||
JsonResult result = this.check(user); | |||
if (0 != result.getCode()) { | |||
log.info("查询用户分页列表业务:校验失败:{}", result.getMsg()); | |||
return result; | |||
} | |||
String tenantId = CurrentUserUtil.getTenantId(); | |||
String tenantId = user.getTenantId(); | |||
request.setTenantId(tenantId); | |||
List<String> deptIdList = this.getDeptIdList(user); | |||
request.setDeptIdList(deptIdList); | |||
// 查询分页数据 | |||
IPage<User> page = new Page<>(request.getPage(), request.getLimit()); | |||
IPage<User> pageData = userMapper.selectPageList(page, request); | |||
@@ -85,13 +91,35 @@ public class QueryUserPageListService { | |||
/** | |||
* 检查参数 | |||
* | |||
* @param request | |||
* @param user | |||
* @return | |||
*/ | |||
private JsonResult check(QueryUserPageListRequest request) { | |||
private JsonResult check(User user) { | |||
if (RoleEnum.ORDINARY_USER.getCode() == user.getRoleId()) { | |||
return JsonResult.error(QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getCode(), QueryUserPageListCodeEnum.ORDINARY_USERS_NO_PERMISSION.getMsg()); | |||
} | |||
return JsonResult.success(); | |||
} | |||
/** | |||
* 获取部门Id的查询范围 | |||
* 1)、超级管理员查全部 | |||
* 2)、部门管理员:查本部门及子部门用户 | |||
* 3)、普通用户:没有权限 | |||
* | |||
* @param user | |||
* @return | |||
*/ | |||
private List<String> getDeptIdList(User user) { | |||
List<String> deptIdList; | |||
if (RoleEnum.SUPER_ADMIN.getCode() == user.getRoleId()) { | |||
return null; | |||
} else { | |||
deptIdList = deptMapper.selectAllChildListById(user.getDeptId()); | |||
return deptIdList; | |||
} | |||
} | |||
/** | |||
* 1)、查找问题类型字段 | |||
* 2)、拼接缩略图路径 |
@@ -90,6 +90,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
<if test="request.username != null and request.username != ''"> and username like concat('%', #{request.username}, '%') </if> | |||
<if test="request.realname != null and request.realname != ''"> and realname like concat('%', #{request.realname}, '%') </if> | |||
<if test="request.roleId != null and request.roleId != 0"> and role_id = #{request.roleId} </if> | |||
<if test="request.deptIdList != null and request.deptIdList.size() > 0"> | |||
and dept_id in | |||
<foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")"> | |||
#{deptId} | |||
</foreach> | |||
</if> | |||
</where> | |||
order by create_time desc | |||
</select> |