|
@@ -21,7 +21,7 @@ import org.eco.common.core.constant.CacheNames;
|
|
|
import org.eco.common.core.constant.Constants;
|
|
|
import org.eco.common.core.constant.TenantConstants;
|
|
|
import org.eco.common.core.core.page.PageResult;
|
|
|
-import org.eco.common.core.exception.ServiceException;
|
|
|
+import org.eco.common.core.exception.BusinessException;
|
|
|
import org.eco.common.core.utils.MapstructUtils;
|
|
|
import org.eco.common.core.utils.SpringUtils;
|
|
|
import org.eco.common.core.utils.StringUtils;
|
|
@@ -168,7 +168,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
return TenantHelper.ignore(() -> {
|
|
|
SysTenant sysTenant = MapstructUtils.convert(sysTenantBo, SysTenant.class);
|
|
|
if (ObjectUtil.isNull(sysTenant)) {
|
|
|
- throw new ServiceException("新增租户参数为空");
|
|
|
+ throw new BusinessException("新增租户参数为空");
|
|
|
}
|
|
|
Long loginUserId = LoginHelper.getUserId();
|
|
|
Date createTime = new Date();
|
|
@@ -178,7 +178,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
sysTenant.setUpdateTime(createTime);
|
|
|
boolean inserted = this.save(sysTenant);
|
|
|
if (!inserted) {
|
|
|
- throw new ServiceException("新增租户失败");
|
|
|
+ throw new BusinessException("新增租户失败");
|
|
|
}
|
|
|
Long tenantId = sysTenant.getTenantId();
|
|
|
|
|
@@ -195,7 +195,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
dept.setDelFlag(0);//0 代表存在
|
|
|
int insertedDeptRows = deptMapper.insert(dept, true);
|
|
|
if (insertedDeptRows != 1) {
|
|
|
- throw new ServiceException("新增租户的部门记录失败");
|
|
|
+ throw new BusinessException("新增租户的部门记录失败");
|
|
|
}
|
|
|
Long deptId = dept.getDeptId();
|
|
|
|
|
@@ -205,7 +205,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
roleDept.setDeptId(deptId);
|
|
|
int insertedRoleDept = roleDeptMapper.insertWithPk(roleDept);
|
|
|
if (insertedRoleDept != 1) {
|
|
|
- throw new ServiceException("新增租户的角色部门记录失败");
|
|
|
+ throw new BusinessException("新增租户的角色部门记录失败");
|
|
|
}
|
|
|
|
|
|
// 新增系统用户
|
|
@@ -220,7 +220,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
user.setUserType("sys_user");//sys_user是系统用户
|
|
|
int insertedUser = userMapper.insert(user, true);
|
|
|
if (insertedUser != 1) {
|
|
|
- throw new ServiceException("新增租户的用户记录失败");
|
|
|
+ throw new BusinessException("新增租户的用户记录失败");
|
|
|
}
|
|
|
|
|
|
// 用户和角色关联表
|
|
@@ -229,7 +229,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
userRole.setRoleId(roleId);
|
|
|
int insertedUserRole = userRoleMapper.insertWithPk(userRole);
|
|
|
if (insertedUserRole != 1) {
|
|
|
- throw new ServiceException("新增租户的用户角色记录失败");
|
|
|
+ throw new BusinessException("新增租户的用户角色记录失败");
|
|
|
}
|
|
|
|
|
|
// 增加字典记录
|
|
@@ -284,7 +284,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
// 获取租户套餐
|
|
|
SysTenantPackageVo tenantPackageVo = tenantPackageService.selectById(packageId);
|
|
|
if (ObjectUtil.isNull(tenantPackageVo)) {
|
|
|
- throw new ServiceException("套餐不存在");
|
|
|
+ throw new BusinessException("套餐不存在");
|
|
|
}
|
|
|
// 获取套餐菜单id
|
|
|
List<Long> menuIds = StringUtils.splitTo(tenantPackageVo.getMenuIds(), Convert::toLong);
|
|
@@ -300,14 +300,14 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
role.setDataScope("1");//默认1:全部数据权限
|
|
|
int insertedRows = roleMapper.insert(role, true);
|
|
|
if (insertedRows != 1) {
|
|
|
- throw new ServiceException("添加租户管理员角色记录失败!");
|
|
|
+ throw new BusinessException("添加租户管理员角色记录失败!");
|
|
|
}
|
|
|
Long roleId = role.getRoleId();
|
|
|
role.setMenuIds(menuIds.toArray(new Long[menuIds.size()]));
|
|
|
//新增角色菜单记录
|
|
|
boolean insertedRoleMenu = roleService.insertRoleMenu(role);
|
|
|
if (!insertedRoleMenu) {
|
|
|
- throw new ServiceException("添加租户管理员的角色菜单记录失败!");
|
|
|
+ throw new BusinessException("添加租户管理员的角色菜单记录失败!");
|
|
|
}
|
|
|
|
|
|
return roleId;
|
|
@@ -323,7 +323,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
return TenantHelper.ignore(() -> {
|
|
|
SysTenant tenant = MapstructUtils.convert(sysTenantBo, SysTenant.class);
|
|
|
if (ObjectUtil.isNull(tenant)) {
|
|
|
- throw new ServiceException("租户的参数为空!");
|
|
|
+ throw new BusinessException("租户的参数为空!");
|
|
|
}
|
|
|
|
|
|
//如果更换了套餐,则需要同步套餐sys_role_menu表
|
|
@@ -331,7 +331,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
if (!oldTenantVo.getPackageId().equals(tenant.getPackageId())) {
|
|
|
boolean synced = syncTenantPackage(tenant.getTenantId(), tenant.getPackageId());
|
|
|
if (!synced) {
|
|
|
- throw new ServiceException("同步套餐失败!");
|
|
|
+ throw new BusinessException("同步套餐失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -372,7 +372,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
@Override
|
|
|
public void checkTenantAllowed(Long tenantId) {
|
|
|
if (ObjectUtil.isNotNull(tenantId) && TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
|
|
- throw new ServiceException("不允许操作超级管理员租户");
|
|
|
+ throw new BusinessException("不允许操作超级管理员租户");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -385,7 +385,7 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
if (isValid) {
|
|
|
// 做一些业务上的校验,判断是否需要校验
|
|
|
if (tenantIds.contains(TenantConstants.SUPER_ADMIN_ID)) {
|
|
|
- throw new ServiceException("超级管理员租户不能删除");
|
|
|
+ throw new BusinessException("超级管理员租户不能删除");
|
|
|
}
|
|
|
}
|
|
|
return TenantHelper.ignore(() -> this.removeByIds(tenantIds));//逻辑删除
|
|
@@ -445,13 +445,13 @@ public class SysTenantServiceImpl extends BaseServiceImpl<SysTenantMapper, SysTe
|
|
|
if (TenantConstants.TENANT_ADMIN_ROLE_KEY.equals(role.getRoleKey())) {
|
|
|
int deletedRoleMenu = roleMenuMapper.deleteByQuery(QueryWrapper.create().from(SYS_ROLE_MENU).where(SYS_ROLE_MENU.ROLE_ID.eq(role.getRoleId())));
|
|
|
if (deletedRoleMenu == 0) {
|
|
|
- throw new ServiceException("删除租户的角色菜单记录失败!");
|
|
|
+ throw new BusinessException("删除租户的角色菜单记录失败!");
|
|
|
}
|
|
|
|
|
|
role.setMenuIds(menuIds.toArray(new Long[menuIds.size()]));
|
|
|
boolean insertedRoleMenu = roleService.insertRoleMenu(role);
|
|
|
if (!insertedRoleMenu) {
|
|
|
- throw new ServiceException("添加租户管理员的角色菜单记录失败!");
|
|
|
+ throw new BusinessException("添加租户管理员的角色菜单记录失败!");
|
|
|
}
|
|
|
} else {
|
|
|
roleIds.add(role.getRoleId());
|