diff --git a/src/main/java/com/guaiguailang/harmony/controller/UserController.java b/src/main/java/com/guaiguailang/harmony/controller/UserController.java index c4d8cd8..d814faf 100644 --- a/src/main/java/com/guaiguailang/harmony/controller/UserController.java +++ b/src/main/java/com/guaiguailang/harmony/controller/UserController.java @@ -34,7 +34,14 @@ public class UserController { tags = {"用户相关接口"} ) @GetMapping("/list") - public ResponseEntity getUserList(ParamUserList userListParam){ + public ResponseEntity getUserList(ParamUserList userListParam,@RequestParam("pageSize") int pageSize,@RequestParam("current") int current){ + // todo 本接口还可以通过RequestParam接受参数 + // column:哪一列(参数内容是列名) + // order:desc 或者 asc 就是降序和升序 + // 就可以实现按某一列排序加载数据 + + userListParam.setPageSize(pageSize); + userListParam.setCurrent(current); return ResponseEntity.ok(userService.getUserList(userListParam)); } @Operation( diff --git a/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserList.java b/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserList.java index 55ce3fb..d9736cb 100644 --- a/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserList.java +++ b/src/main/java/com/guaiguailang/harmony/domain/dto/ParamUserList.java @@ -8,5 +8,6 @@ public class ParamUserList { String userType; // 分页 int pageSize; - int currentPage; + int current; + String order; } diff --git a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java index 285e3d8..027bc47 100644 --- a/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java +++ b/src/main/java/com/guaiguailang/harmony/service/impl/UserServiceImpl.java @@ -101,14 +101,14 @@ public class UserServiceImpl implements UserService { String merchantCode= Objects.equals(userInfo.getRoleId(), "root") || Objects.equals(userInfo.getRoleId(), "admin") ?"ALL":userInfo.getMerchantCode(); int currentLevel = authMapper.getRoleLevelByRole(userInfo.getRoleId()); // 计算查询limit - int limit = (userListParam.getCurrentPage()-1) * userListParam.getPageSize(); + int limit = (userListParam.getCurrent()-1) * userListParam.getPageSize(); int end = limit + userListParam.getPageSize(); // 创建一个查询条件来排除当前用户 Map queryConditions = new HashMap<>(); queryConditions.put("excludeUid", uid); queryConditions.put("currentLevel", currentLevel); // 添加当前用户的等级作为查询条件 List userInfos; - log.info("要查询的用户类型是:"+userListParam.getUserType()); + log.info("要查询的用户类型是:{}", userListParam.getUserType()); if (Objects.equals(userListParam.getUserType(), "activate")) { // 如果有额外的激活状态条件,也可以加入到queryConditions中,比如限制不能查询身份等级比自己高的 | todo 这个任务涉及到新增字段 | 已经新增字段level。level数值越小,则身份权限越高,后面不管怎么查,都只能查询level值>当前用户level值的 userInfos = userMapper.getUserListActivate(limit, end, merchantCode, queryConditions);