From d573fb776f8bb08bf6b160b8eb8305a10a0c7a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E7=8B=BC=E8=93=9D=E5=A4=A9?= Date: Sat, 19 Oct 2024 02:15:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=EF=BC=9A=E9=80=82=E9=85=8D?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=AB=AF=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=80=BB=E6=95=B0=E6=8D=AE=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guaiguailang/harmony/controller/UserController.java | 9 ++++++++- .../guaiguailang/harmony/domain/dto/ParamUserList.java | 3 ++- .../harmony/service/impl/UserServiceImpl.java | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) 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);