From 49196059f24f3886b7454052a611ca2df786fad4 Mon Sep 17 00:00:00 2001 From: liuchen864 <23082234@qq.com> Date: Thu, 23 Nov 2023 16:22:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=8B=E5=8A=A1bug?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/permission/PermissionServiceImpl.java | 7 +++---- .../system/service/tenant/TenantPackageServiceImpl.java | 3 ++- .../module/system/service/tenant/TenantServiceImpl.java | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/permission/PermissionServiceImpl.java b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/permission/PermissionServiceImpl.java index aad386f..1fe7be9 100644 --- a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/permission/PermissionServiceImpl.java +++ b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/permission/PermissionServiceImpl.java @@ -131,9 +131,8 @@ public class PermissionServiceImpl implements PermissionService { // ========== 角色-菜单的相关方法 ========== @Override - @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 - @CacheEvict(value = RedisKeyConstants.MENU_ROLE_ID_LIST, - allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快 + @Transactional + @CacheEvict(value = RedisKeyConstants.MENU_ROLE_ID_LIST, allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快 public void assignRoleMenu(Long roleId, Set menuIds) { // 获得角色拥有菜单编号 Set dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), RoleMenuDO::getMenuId); @@ -198,7 +197,7 @@ public class PermissionServiceImpl implements PermissionService { // ========== 用户-角色的相关方法 ========== @Override - @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 + @Transactional @CacheEvict(value = RedisKeyConstants.USER_ROLE_ID_LIST, key = "#userId") public void assignUserRole(Long userId, Set roleIds) { // 获得角色拥有角色编号 diff --git a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantPackageServiceImpl.java b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantPackageServiceImpl.java index 222c89e..5330570 100644 --- a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantPackageServiceImpl.java +++ b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantPackageServiceImpl.java @@ -13,6 +13,7 @@ import com.win.module.system.dal.mysql.tenant.TenantPackageMapper; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -47,7 +48,7 @@ public class TenantPackageServiceImpl implements TenantPackageService { } @Override - @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 + @Transactional public void updateTenantPackage(TenantPackageUpdateReqVO updateReqVO) { // 校验存在 TenantPackageDO tenantPackage = validateTenantPackageExists(updateReqVO.getId()); diff --git a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantServiceImpl.java b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantServiceImpl.java index c11b631..de3bf3a 100644 --- a/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantServiceImpl.java +++ b/win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantServiceImpl.java @@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -95,7 +96,7 @@ public class TenantServiceImpl implements TenantService { } @Override - @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 + @Transactional public Long createTenant(TenantCreateReqVO createReqVO) { // 校验租户名称是否重复 validTenantNameDuplicate(createReqVO.getName(), null); @@ -137,7 +138,7 @@ public class TenantServiceImpl implements TenantService { } @Override - @DSTransactional + @Transactional public void updateTenant(TenantUpdateReqVO updateReqVO) { // 校验存在 TenantDO tenant = validateUpdateTenant(updateReqVO.getId()); @@ -170,7 +171,7 @@ public class TenantServiceImpl implements TenantService { } @Override - @DSTransactional + @Transactional public void updateTenantRoleMenu(Long tenantId, Set menuIds) { TenantUtils.execute(tenantId, () -> { // 获得所有角色