From a46c4bf04e3c52ab16f5ed960105088f515c3917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 8 Jun 2022 13:53:08 +0000 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8E=E8=A7=92=E8=89=B2=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E3=80=81=E7=94=A8=E6=88=B7=E4=B8=8E=E5=B2=97=E4=BD=8D=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysUserServiceImpl.java | 36 ++++--------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 56f3dac7..bf4ca172 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -381,23 +381,7 @@ public class SysUserServiceImpl implements ISysUserService */ public void insertUserRole(SysUser user) { - Long[] roles = user.getRoleIds(); - if (StringUtils.isNotNull(roles)) - { - // 新增用户与角色管理 - List list = new ArrayList(); - for (Long roleId : roles) - { - SysUserRole ur = new SysUserRole(); - ur.setUserId(user.getUserId()); - ur.setRoleId(roleId); - list.add(ur); - } - if (list.size() > 0) - { - userRoleMapper.batchUserRole(list); - } - } + this.insertUserRole(user.getUserId, user.getRoleIds()); } /** @@ -408,10 +392,10 @@ public class SysUserServiceImpl implements ISysUserService public void insertUserPost(SysUser user) { Long[] posts = user.getPostIds(); - if (StringUtils.isNotNull(posts)) + if (StringUtils.isNotEmpty(posts)) { // 新增用户与岗位管理 - List list = new ArrayList(); + List list = new ArrayList(posts.length); for (Long postId : posts) { SysUserPost up = new SysUserPost(); @@ -419,10 +403,7 @@ public class SysUserServiceImpl implements ISysUserService up.setPostId(postId); list.add(up); } - if (list.size() > 0) - { - userPostMapper.batchUserPost(list); - } + userPostMapper.batchUserPost(list); } } @@ -434,10 +415,10 @@ public class SysUserServiceImpl implements ISysUserService */ public void insertUserRole(Long userId, Long[] roleIds) { - if (StringUtils.isNotNull(roleIds)) + if (StringUtils.isNotEmpty(roleIds)) { // 新增用户与角色管理 - List list = new ArrayList(); + List list = new ArrayList(roleIds.length); for (Long roleId : roleIds) { SysUserRole ur = new SysUserRole(); @@ -445,10 +426,7 @@ public class SysUserServiceImpl implements ISysUserService ur.setRoleId(roleId); list.add(ur); } - if (list.size() > 0) - { - userRoleMapper.batchUserRole(list); - } + userRoleMapper.batchUserRole(list); } }