Browse Source

修改事务bug。

master
liuchen864 1 year ago
parent
commit
49196059f2
  1. 7
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/permission/PermissionServiceImpl.java
  2. 3
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantPackageServiceImpl.java
  3. 7
      win-module-system/win-module-system-biz/src/main/java/com/win/module/system/service/tenant/TenantServiceImpl.java

7
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<Long> menuIds) {
// 获得角色拥有菜单编号
Set<Long> 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<Long> roleIds) {
// 获得角色拥有角色编号

3
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());

7
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<Long> menuIds) {
TenantUtils.execute(tenantId, () -> {
// 获得所有角色

Loading…
Cancel
Save