/** | /** | ||||
* 新增用户返回码 | * 新增用户返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:01 (新增用户) | * 接口代码:01 (新增用户) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 删除用户返回码 | * 删除用户返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:02 (删除用户) | * 接口代码:02 (删除用户) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 删除用户返回码 | * 删除用户返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:03 (删除用户) | * 接口代码:03 (删除用户) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 修改用户密码返回码 | * 修改用户密码返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:04 (修改用户密码) | * 接口代码:04 (修改用户密码) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 修改用户状态返回码 | * 修改用户状态返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:05 (修改用户状态) | * 接口代码:05 (修改用户状态) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 根据ID查询用户信息返回码 | * 根据ID查询用户信息返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:06 (根据ID查询用户信息) | * 接口代码:06 (根据ID查询用户信息) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
/** | /** | ||||
* 根据部门ID查询用户列表返回码 | * 根据部门ID查询用户列表返回码 | ||||
* 模块代码:10(部门管理) | |||||
* 模块代码:10(用户管理) | |||||
* 接口代码:07 (据部门ID查询用户列表) | * 接口代码:07 (据部门ID查询用户列表) | ||||
* | * | ||||
* @author wanjing | * @author wanjing |
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; | |||||
} | |||||
} |
import com.tuoheng.common.core.common.BaseQuery; | import com.tuoheng.common.core.common.BaseQuery; | ||||
import lombok.Data; | import lombok.Data; | ||||
import java.util.List; | |||||
/** | /** | ||||
* 用户查询条件 | * 用户查询条件 | ||||
*/ | */ | ||||
*/ | */ | ||||
private Integer roleId; | private Integer roleId; | ||||
/** | |||||
* 部门及子部门Id列表 | |||||
*/ | |||||
private List<String> deptIdList; | |||||
} | } |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.tuoheng.admin.conver.UserConverMapper; | import com.tuoheng.admin.conver.UserConverMapper; | ||||
import com.tuoheng.admin.entity.*; | 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.DeptMapper; | ||||
import com.tuoheng.admin.mapper.RoleMapper; | import com.tuoheng.admin.mapper.RoleMapper; | ||||
import com.tuoheng.admin.mapper.UserMapper; | import com.tuoheng.admin.mapper.UserMapper; | ||||
*/ | */ | ||||
public JsonResult getPageList(QueryUserPageListRequest request) { | public JsonResult getPageList(QueryUserPageListRequest request) { | ||||
log.info("进入查询用户分页列表业务"); | log.info("进入查询用户分页列表业务"); | ||||
JsonResult result = this.check(request); | |||||
User user = CurrentUserUtil.getUserInfo(); | |||||
JsonResult result = this.check(user); | |||||
if (0 != result.getCode()) { | if (0 != result.getCode()) { | ||||
log.info("查询用户分页列表业务:校验失败:{}", result.getMsg()); | log.info("查询用户分页列表业务:校验失败:{}", result.getMsg()); | ||||
return result; | return result; | ||||
} | } | ||||
String tenantId = CurrentUserUtil.getTenantId(); | |||||
String tenantId = user.getTenantId(); | |||||
request.setTenantId(tenantId); | request.setTenantId(tenantId); | ||||
List<String> deptIdList = this.getDeptIdList(user); | |||||
request.setDeptIdList(deptIdList); | |||||
// 查询分页数据 | // 查询分页数据 | ||||
IPage<User> page = new Page<>(request.getPage(), request.getLimit()); | IPage<User> page = new Page<>(request.getPage(), request.getLimit()); | ||||
IPage<User> pageData = userMapper.selectPageList(page, request); | IPage<User> pageData = userMapper.selectPageList(page, request); | ||||
/** | /** | ||||
* 检查参数 | * 检查参数 | ||||
* | * | ||||
* @param request | |||||
* @param user | |||||
* @return | * @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(); | 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)、查找问题类型字段 | * 1)、查找问题类型字段 | ||||
* 2)、拼接缩略图路径 | * 2)、拼接缩略图路径 |
<if test="request.username != null and request.username != ''"> and username like concat('%', #{request.username}, '%') </if> | <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.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.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> | </where> | ||||
order by create_time desc | order by create_time desc | ||||
</select> | </select> |