From 80c4385c5ddc5147b237bc8155b865202d5c0df2 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 8 Sep 2023 10:20:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dsql=E6=B3=A8=E5=85=A5?= =?UTF-8?q?=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/sys/SysUserController.java | 14 +++----- .../sys/request/UserGridRequest.java | 19 +++++++++++ .../io/dataease/ext/ExtSysUserMapper.java | 3 +- .../java/io/dataease/ext/ExtSysUserMapper.xml | 32 +++++++++++++------ .../dataease/service/sys/SysUserService.java | 8 ++--- core/frontend/src/utils/GridConditionUtil.js | 28 ++++++++++++++++ .../src/views/system/user/FilterUser.vue | 6 ++-- core/frontend/src/views/system/user/index.vue | 23 +++++++------ .../common/request/KeywordRequest.java | 16 ++++++++++ 9 files changed, 109 insertions(+), 40 deletions(-) create mode 100644 core/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java create mode 100644 core/frontend/src/utils/GridConditionUtil.js create mode 100644 sdk/dataease-plugin-common/src/main/java/io/dataease/plugins/common/request/KeywordRequest.java diff --git a/core/backend/src/main/java/io/dataease/controller/sys/SysUserController.java b/core/backend/src/main/java/io/dataease/controller/sys/SysUserController.java index 5f46a52c0d..980a916ce0 100644 --- a/core/backend/src/main/java/io/dataease/controller/sys/SysUserController.java +++ b/core/backend/src/main/java/io/dataease/controller/sys/SysUserController.java @@ -19,10 +19,7 @@ import io.dataease.commons.utils.PageUtils; import io.dataease.commons.utils.Pager; import io.dataease.controller.response.ExistLdapUser; import io.dataease.controller.sys.base.BaseGridRequest; -import io.dataease.controller.sys.request.KeyGridRequest; -import io.dataease.controller.sys.request.SysUserCreateRequest; -import io.dataease.controller.sys.request.SysUserPwdRequest; -import io.dataease.controller.sys.request.SysUserStateRequest; +import io.dataease.controller.sys.request.*; import io.dataease.controller.sys.response.AuthBindDTO; import io.dataease.controller.sys.response.RoleUserItem; import io.dataease.controller.sys.response.SysUserGridResponse; @@ -81,7 +78,7 @@ public class SysUserController { }) @SqlInjectValidator(value = {"create_time", "u.enabled", "nick_name", "u.dept_id"}) public Pager> userGrid(@PathVariable int goPage, @PathVariable int pageSize, - @RequestBody KeyGridRequest request) { + @RequestBody UserGridRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); List users = sysUserService.query(request); users.forEach(user -> { @@ -95,9 +92,8 @@ public class SysUserController { @ApiIgnore @PostMapping("/userLists") @SqlInjectValidator({"nick_name", "create_time"}) - public List userLists(@RequestBody BaseGridRequest request) { - KeyGridRequest keyGridRequest = BeanUtils.copyBean(new KeyGridRequest(), request); - List users = sysUserService.query(keyGridRequest); + public List userLists(@RequestBody UserGridRequest request) { + List users = sysUserService.query(request); if (CollectionUtils.isEmpty(users)) return users; users.forEach(user -> { user.setPassword(null); @@ -113,7 +109,7 @@ public class SysUserController { @ApiImplicitParam(name = "request", value = "查询条件", required = true) }) @SqlInjectValidator(value = {"create_time", "u.enabled", "nick_name", "u.dept_id"}) - public Pager> userGrids(@PathVariable String datasetId, @RequestBody KeyGridRequest request) { + public Pager> userGrids(@PathVariable String datasetId, @RequestBody UserGridRequest request) { return userGrid(0, 0, request); } diff --git a/core/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java b/core/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java new file mode 100644 index 0000000000..9677ce7098 --- /dev/null +++ b/core/backend/src/main/java/io/dataease/controller/sys/request/UserGridRequest.java @@ -0,0 +1,19 @@ +package io.dataease.controller.sys.request; + +import io.dataease.plugins.common.request.KeywordRequest; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class UserGridRequest extends KeywordRequest { + + @ApiModelProperty("角色ID列表") + private List roleIdList; + @ApiModelProperty("组织ID列表") + private List deptIdList; + @ApiModelProperty("状态") + private List enabledList; + +} diff --git a/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.java b/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.java index 37996adfe1..953fd867d8 100644 --- a/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.java +++ b/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.java @@ -1,12 +1,13 @@ package io.dataease.ext; +import io.dataease.controller.sys.request.UserGridRequest; import io.dataease.ext.query.GridExample; import io.dataease.controller.sys.response.SysUserGridResponse; import java.util.List; public interface ExtSysUserMapper { - List query(GridExample example); + List query(UserGridRequest request); List ldapUserNames(Integer from); diff --git a/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml b/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml index c4921381fa..7f873a23c6 100644 --- a/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml +++ b/core/backend/src/main/java/io/dataease/ext/ExtSysUserMapper.xml @@ -33,7 +33,7 @@ - SELECT DISTINCT u.*, u.user_id AS id, @@ -42,26 +42,38 @@ FROM ( select * from sys_user - + where - nick_name like concat('%', #{extendCondition} , '%') + nick_name like concat('%', #{keyword} , '%') or - email like concat('%', #{extendCondition} , '%') + email like concat('%', #{keyword} , '%') ) u LEFT JOIN sys_dept d ON d.dept_id = u.dept_id LEFT JOIN sys_users_roles sur ON sur.user_id = u.user_id LEFT JOIN sys_role r ON r.role_id = sur.role_id + where 1 = 1 - - + + and r.role_id in + + #{roleId} + - - order by ${orderByClause} + + and d.dept_id in + + #{deptId} + - - order by u.update_time desc + + and u.enabled in + + #{en} + + +