diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserRoleService.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserRoleService.java index 23451aed6..c585d9e27 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserRoleService.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/SysUserRoleService.java @@ -59,4 +59,12 @@ public interface SysUserRoleService extends IService, SysUserRoleSe */ void updateOtherOrgBusinessRole(Long userId, Long excludeOrgId, List currentOrgBindRoleList); + /** + * 批量保存用户角色 + * + * @author fengshuonan + * @since 2024/2/12 23:13 + */ + void quickBatchSaveUserRole(List batchUserRole); + } \ No newline at end of file diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserRoleServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserRoleServiceImpl.java index 39343e9a0..31d015a09 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserRoleServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserRoleServiceImpl.java @@ -4,8 +4,10 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.stylefeng.roses.kernel.auth.api.context.LoginContext; import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi; +import cn.stylefeng.roses.kernel.dsctn.api.context.DataSourceContext; import cn.stylefeng.roses.kernel.event.sdk.publish.BusinessEventPublisher; import cn.stylefeng.roses.kernel.log.api.util.BusinessLogUtil; +import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; import cn.stylefeng.roses.kernel.sys.api.SysRoleLimitServiceApi; import cn.stylefeng.roses.kernel.sys.api.SysRoleServiceApi; @@ -339,6 +341,16 @@ public class SysUserRoleServiceImpl extends ServiceImpl batchUserRole) { + if (DbTypeEnum.MYSQL.equals(DataSourceContext.me().getCurrentDbType())) { + this.getBaseMapper().insertBatchSomeColumn(batchUserRole); + } else { + this.saveBatch(batchUserRole); + } + } + /** * 清空用户绑定的所有系统角色,这个界面只管分配系统角色 * diff --git a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java index 1e0bf14d0..ca428685a 100644 --- a/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java +++ b/kernel-s-system/system-business-hr/src/main/java/cn/stylefeng/roses/kernel/sys/modular/user/service/impl/SysUserServiceImpl.java @@ -412,6 +412,7 @@ public class SysUserServiceImpl extends ServiceImpl impl } @Override + @Transactional(rollbackFor = Exception.class) public void quickBatchSaveUser(List batchUser) { if (DbTypeEnum.MYSQL.equals(DataSourceContext.me().getCurrentDbType())) { this.getBaseMapper().insertBatchSomeColumn(batchUser);