From 2ea91d781117ff61a80757320016c3b8c78ea7b2 Mon Sep 17 00:00:00 2001 From: oddfar Date: Wed, 21 Feb 2024 14:50:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0null=E7=9A=84=E8=A7=92?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/service/impl/SysUserServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/campus-framework/src/main/java/com/oddfar/campus/framework/service/impl/SysUserServiceImpl.java b/campus-framework/src/main/java/com/oddfar/campus/framework/service/impl/SysUserServiceImpl.java index 3a60f1f..c3ffaf8 100644 --- a/campus-framework/src/main/java/com/oddfar/campus/framework/service/impl/SysUserServiceImpl.java +++ b/campus-framework/src/main/java/com/oddfar/campus/framework/service/impl/SysUserServiceImpl.java @@ -249,10 +249,12 @@ public void insertUserRole(Long userId, Long[] roleIds) { // 新增用户与角色管理 List list = new ArrayList(roleIds.length); for (Long roleId : roleIds) { - SysUserRoleEntity ur = new SysUserRoleEntity(); - ur.setUserId(userId); - ur.setRoleId(roleId); - list.add(ur); + if (roleId != null) { + SysUserRoleEntity ur = new SysUserRoleEntity(); + ur.setUserId(userId); + ur.setRoleId(roleId); + list.add(ur); + } } userRoleMapper.insertBatch(list); }