From ecca9ab70a9a87bcb60977c92fbf81053b8fc1bb Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期三, 04 九月 2024 09:17:55 +0800 Subject: [PATCH] 新增优化 --- ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/UserController.java | 27 ++++++++++++++++++++++++++- 1 files changed, 26 insertions(+), 1 deletions(-) diff --git a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/UserController.java b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/UserController.java index 381e785..f98a5be 100644 --- a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/UserController.java +++ b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/UserController.java @@ -8,6 +8,10 @@ import com.ruoyi.admin.service.UserService; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.common.security.annotation.RequiresPermissions; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.api.feignClient.OrderClient; +import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -34,13 +38,18 @@ @Resource private UserService userService; + @Resource + private TokenService tokenService; + @Resource + private OrderClient orderClient; /** * 用户信息分页列表 * * @param pageNum 页码 * @param pageSize 每页显示条数 */ + @RequiresPermissions("user_list") @ApiOperation(value = "用户列表", tags = {"用户管理-用户列表"}) @GetMapping(value = "/page") @ApiImplicitParams({ @@ -53,12 +62,25 @@ public R<IPage<User>> queryPageList(String nickname, String phone, Integer state, @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { - LambdaQueryChainWrapper<User> query = userService.lambdaQuery(); + LoginUser loginUser = tokenService.getLoginUser(); + if (null == loginUser) { + return R.loginExpire("登录失效!"); + } + LambdaQueryChainWrapper<User> query = userService.lambdaQuery().isNotNull(User::getPhone); // 穆湖匹配规则 query = StringUtils.isNotBlank(nickname) ? query.like(User::getNickname, nickname) : query; query = StringUtils.isNotBlank(phone) ? query.like(User::getPhone, phone) : query; // 账号是否启用 query = null != state ? query.eq(User::getState, state) : query; +// if (loginUser.getIsFranchisee() && !loginUser.getCityList().isEmpty()) { +// query.in(User::getCity, loginUser.getCityList()); +// } + if (loginUser.getIsFranchisee()) { + List<String> cityList = loginUser.getCityList(); + R<List<Integer>> listR = orderClient.queryIdsBycode(cityList); + return R.ok(query.orderByDesc(User::getCreateTime).eq(User::getIsDelete, 0) + .orderByDesc(User::getCreateTime).in(User::getId, listR.getData()).page(Page.of(pageNum, pageSize))); + } return R.ok(query.orderByDesc(User::getCreateTime).eq(User::getIsDelete, 0) .orderByDesc(User::getCreateTime).page(Page.of(pageNum, pageSize))); } @@ -68,6 +90,7 @@ * * @param id 前台用户id */ + @RequiresPermissions("user_detail") @ApiOperation(value = "用户详情", tags = {"用户管理-用户列表"}) @GetMapping(value = "/detail") @ApiImplicitParams({ @@ -83,6 +106,7 @@ * @param id 后台账号id * @param enable 启用/关闭 */ + @RequiresPermissions("user_enable") @ApiOperation(value = "启用/关闭用户账号", tags = {"用户管理-用户列表"}) @GetMapping(value = "/enable") @ApiImplicitParams({ @@ -111,6 +135,7 @@ * * @param ids 前台用户多条id拼接 */ + @RequiresPermissions("user_delete") @ApiOperation(value = "批量删除用户", tags = {"用户管理-用户列表"}) @GetMapping(value = "/batchDelete") @ApiImplicitParams({ -- Gitblit v1.7.1