|
@@ -1,9 +1,6 @@
|
|
|
package cn.cslg.permission.service;
|
|
|
|
|
|
-import cn.cslg.permission.common.model.vo.DataVO;
|
|
|
-import cn.cslg.permission.common.model.vo.PersonnelVO;
|
|
|
-import cn.cslg.permission.common.model.vo.RoleVO;
|
|
|
-import cn.cslg.permission.common.model.vo.TenantVO;
|
|
|
+import cn.cslg.permission.common.model.vo.*;
|
|
|
import cn.cslg.permission.common.utils.CacheUtils;
|
|
|
import cn.cslg.permission.common.utils.DataUtils;
|
|
|
import cn.cslg.permission.common.utils.Response;
|
|
@@ -12,6 +9,8 @@ import cn.cslg.permission.domain.Department;
|
|
|
import cn.cslg.permission.domain.Personnel;
|
|
|
import cn.cslg.permission.domain.Role;
|
|
|
import cn.cslg.permission.domain.Tenant;
|
|
|
+import cn.cslg.permission.domain.associate.AssoTenantFunction;
|
|
|
+import cn.cslg.permission.mapper.AssoTenantVipTypeFunctionMapper;
|
|
|
import cn.cslg.permission.mapper.TenantEntityMapper;
|
|
|
import cn.cslg.permission.service.associate.PersonRoleService;
|
|
|
import cn.cslg.permission.service.associate.RoleFunctionDataService;
|
|
@@ -28,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author 沈永艺
|
|
@@ -45,6 +45,7 @@ public class TenantService extends ServiceImpl<TenantEntityMapper, Tenant> {
|
|
|
private final PersonRoleService personRoleService;
|
|
|
private final DeleteService deleteService;
|
|
|
private final CacheUtils cacheUtils;
|
|
|
+ private final AssoTenantVipTypeFunctionMapper assoTenantVipTypeFunctionMapper; //租户会员类型id和功能的关联表的Mapper层装配
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String addTenant(TenantVO tenantVO) {
|
|
@@ -67,6 +68,7 @@ public class TenantService extends ServiceImpl<TenantEntityMapper, Tenant> {
|
|
|
.setTenantQuota((tenantVO.getNumber()))
|
|
|
.setTenantStatus(tenantVO.getState())
|
|
|
.setTenantType(tenantVO.getType())
|
|
|
+ .setTenantVipType(tenantVO.getTenantVipType())
|
|
|
.setCreateUser(StpUtil.getLoginIdAsInt());
|
|
|
boolean suc = this.save(tenant);
|
|
|
if (suc) {
|
|
@@ -85,8 +87,22 @@ public class TenantService extends ServiceImpl<TenantEntityMapper, Tenant> {
|
|
|
tenant.setPersonnelId(personnel.getId());
|
|
|
tenant.updateById();
|
|
|
}
|
|
|
+
|
|
|
//租户功能关联表保存信息
|
|
|
+ Integer tenantVipTypeId = tenant.getTenantVipType();
|
|
|
+ List<AssoTenantVipTypeAndFunctionVO> assoTenantVipTypeAndFunctionVOS = assoTenantVipTypeFunctionMapper.selectByTenantVipTypeId(tenant.getTenantVipType());
|
|
|
+ List<String> functions = tenantVO.getFunctions();
|
|
|
+ List<List<Integer>> functionIds = new ArrayList<>();
|
|
|
+ for (AssoTenantVipTypeAndFunctionVO assoTenantVipTypeAndFunctionVO : assoTenantVipTypeAndFunctionVOS) {
|
|
|
+ String functionModifyPath = assoTenantVipTypeAndFunctionVO.getFunctionModifyPath();
|
|
|
+ functions.add(functionModifyPath);
|
|
|
+ //将以逗号分隔的功能组件树字符串路径转换为Integer集合
|
|
|
+ List<Integer> functionId = Arrays.stream(functionModifyPath.split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
|
|
+ functionIds.add(functionId);
|
|
|
+ }
|
|
|
+ tenantVO.setFunction(functionIds);
|
|
|
tenantFunctionService.add(tenantVO, tenant);
|
|
|
+
|
|
|
//角色功能权限关联表,角色表保存信息
|
|
|
List<RoleVO.Permission> permissions = new ArrayList<>();
|
|
|
if (tenantVO.getFunction() != null) {
|
|
@@ -219,7 +235,7 @@ public class TenantService extends ServiceImpl<TenantEntityMapper, Tenant> {
|
|
|
public IPage<Tenant> getTenants(Integer tenantId, String tenantName, List<String> names, Integer current, Integer size) {
|
|
|
IPage<Tenant> tenants;
|
|
|
LambdaQueryWrapper<Tenant> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- if (names != null&& names.size()!=0) {
|
|
|
+ if (names != null && names.size() != 0) {
|
|
|
lambdaQueryWrapper.like(Tenant::getTenantName, tenantName).eq(Tenant::getTenantStatus, 1);
|
|
|
lambdaQueryWrapper.and(wrapper -> wrapper.in(Tenant::getTenantName, names).or().eq(Tenant::getId, tenantId));
|
|
|
} else {
|