适配:适配管理端用户管理总数据加载

This commit is contained in:
萌狼蓝天 2024-10-19 02:15:36 +08:00
parent 76be7ca3e5
commit d573fb776f
3 changed files with 12 additions and 4 deletions

View File

@ -34,7 +34,14 @@ public class UserController {
tags = {"用户相关接口"} tags = {"用户相关接口"}
) )
@GetMapping("/list") @GetMapping("/list")
public ResponseEntity getUserList(ParamUserList userListParam){ public ResponseEntity getUserList(ParamUserList userListParam,@RequestParam("pageSize") int pageSize,@RequestParam("current") int current){
// todo 本接口还可以通过RequestParam接受参数
// column哪一列参数内容是列名
// orderdesc 或者 asc 就是降序和升序
// 就可以实现按某一列排序加载数据
userListParam.setPageSize(pageSize);
userListParam.setCurrent(current);
return ResponseEntity.ok(userService.getUserList(userListParam)); return ResponseEntity.ok(userService.getUserList(userListParam));
} }
@Operation( @Operation(

View File

@ -8,5 +8,6 @@ public class ParamUserList {
String userType; String userType;
// 分页 // 分页
int pageSize; int pageSize;
int currentPage; int current;
String order;
} }

View File

@ -101,14 +101,14 @@ public class UserServiceImpl implements UserService {
String merchantCode= Objects.equals(userInfo.getRoleId(), "root") || Objects.equals(userInfo.getRoleId(), "admin") ?"ALL":userInfo.getMerchantCode(); String merchantCode= Objects.equals(userInfo.getRoleId(), "root") || Objects.equals(userInfo.getRoleId(), "admin") ?"ALL":userInfo.getMerchantCode();
int currentLevel = authMapper.getRoleLevelByRole(userInfo.getRoleId()); int currentLevel = authMapper.getRoleLevelByRole(userInfo.getRoleId());
// 计算查询limit // 计算查询limit
int limit = (userListParam.getCurrentPage()-1) * userListParam.getPageSize(); int limit = (userListParam.getCurrent()-1) * userListParam.getPageSize();
int end = limit + userListParam.getPageSize(); int end = limit + userListParam.getPageSize();
// 创建一个查询条件来排除当前用户 // 创建一个查询条件来排除当前用户
Map<String, Object> queryConditions = new HashMap<>(); Map<String, Object> queryConditions = new HashMap<>();
queryConditions.put("excludeUid", uid); queryConditions.put("excludeUid", uid);
queryConditions.put("currentLevel", currentLevel); // 添加当前用户的等级作为查询条件 queryConditions.put("currentLevel", currentLevel); // 添加当前用户的等级作为查询条件
List<UserInfo> userInfos; List<UserInfo> userInfos;
log.info("要查询的用户类型是:"+userListParam.getUserType()); log.info("要查询的用户类型是:{}", userListParam.getUserType());
if (Objects.equals(userListParam.getUserType(), "activate")) { if (Objects.equals(userListParam.getUserType(), "activate")) {
// 如果有额外的激活状态条件也可以加入到queryConditions中,比如限制不能查询身份等级比自己高的 | todo 这个任务涉及到新增字段 | 已经新增字段levellevel数值越小则身份权限越高后面不管怎么查都只能查询level值>当前用户level值的 // 如果有额外的激活状态条件也可以加入到queryConditions中,比如限制不能查询身份等级比自己高的 | todo 这个任务涉及到新增字段 | 已经新增字段levellevel数值越小则身份权限越高后面不管怎么查都只能查询level值>当前用户level值的
userInfos = userMapper.getUserListActivate(limit, end, merchantCode, queryConditions); userInfos = userMapper.getUserListActivate(limit, end, merchantCode, queryConditions);