|
@@ -4,14 +4,11 @@ import cn.cslg.permission.common.JsonPage;
|
|
|
import cn.cslg.permission.common.model.dto.PageDTO2;
|
|
|
import cn.cslg.permission.common.model.dto.TenantVipTypeFunctionAddNewDTO;
|
|
|
import cn.cslg.permission.common.model.dto.TenantVipTypeFunctionUpdateDTO;
|
|
|
-import cn.cslg.permission.common.model.vo.FunctionVO2;
|
|
|
-import cn.cslg.permission.common.model.vo.TenantVO;
|
|
|
import cn.cslg.permission.common.model.vo.TenantVipTypeFunctionVO;
|
|
|
import cn.cslg.permission.common.utils.ThrowException;
|
|
|
import cn.cslg.permission.domain.AssoTenantVipTypeAndFunction;
|
|
|
import cn.cslg.permission.domain.FunctionIdPathNameDescription;
|
|
|
import cn.cslg.permission.domain.TenantVipType;
|
|
|
-import cn.cslg.permission.exception.XiaoShiException;
|
|
|
import cn.cslg.permission.mapper.AssoTenantVipTypeFunctionMapper;
|
|
|
import cn.cslg.permission.mapper.FunctionMapper;
|
|
|
import cn.cslg.permission.mapper.TenantMapper;
|
|
@@ -53,7 +50,7 @@ public class TenantVipTypeService extends ServiceImpl<TenantVipTypeMapper, Tenan
|
|
|
* @param tenantVipTypeFunctionAddNewDTO 租户会员类型和功能数据对象
|
|
|
*/
|
|
|
@Override
|
|
|
- public void addNew(TenantVipTypeFunctionAddNewDTO tenantVipTypeFunctionAddNewDTO) {
|
|
|
+ public Integer addNew(TenantVipTypeFunctionAddNewDTO tenantVipTypeFunctionAddNewDTO) {
|
|
|
log.info("开始处理【新增租户会员类型】的业务,参数为:{}", tenantVipTypeFunctionAddNewDTO);
|
|
|
|
|
|
//检查会员名称是否已存在
|
|
@@ -82,39 +79,40 @@ public class TenantVipTypeService extends ServiceImpl<TenantVipTypeMapper, Tenan
|
|
|
ArrayList<AssoTenantVipTypeAndFunction> assoTenantVipTypeAndFunctions = new ArrayList<>();
|
|
|
//从DTO中取出功能组件权限路径集合,遍历集合给会员和功能关联表实体类赋值
|
|
|
List<String> functionModifyPaths = tenantVipTypeFunctionAddNewDTO.getFunctionModifyPaths();
|
|
|
- for (String functionModifyPath : functionModifyPaths) {
|
|
|
- //从功能组件树路径中提取出功能id
|
|
|
- //仁杰的方法:int functionId = Integer.parseInt(functionModifyPath.split(",")[functionModifyPath.split(",").length - 1])
|
|
|
- int functionId = Integer.parseInt(functionModifyPath.substring(functionModifyPath.lastIndexOf(",") + 1));
|
|
|
- //租户会员类型tenantVipTypeId、功能functionId、功能组件树路径functionModifyPath赋值给租户会员类型和功能关联表实体类
|
|
|
- AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction = new AssoTenantVipTypeAndFunction()
|
|
|
- .setTenantVipTypeId(tenantVipTypeId)
|
|
|
- .setFunctionId(functionId)
|
|
|
- .setFunctionModifyPath(functionModifyPath);
|
|
|
- assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction);
|
|
|
-// //根据当前功能id查询其下未展示的子级功能
|
|
|
-// List<FunctionVO2> functionVO2s = functionMapper.selectNotShowChildrenById(functionId);
|
|
|
-// for (FunctionVO2 functionVO2 : functionVO2s) {
|
|
|
-// String path = functionVO2.getPath();
|
|
|
-// Integer notShowChidlrenFunctionId = functionVO2.getId();
|
|
|
-// Integer applicationId = functionVO2.getApplicationId();
|
|
|
-// String notShowChildrenFunctionModifyPath = applicationId + "," + path.substring(path.indexOf(",") + 1) + "," + notShowChidlrenFunctionId;
|
|
|
-// AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction2 = new AssoTenantVipTypeAndFunction()
|
|
|
-// .setTenantVipTypeId(tenantVipTypeId)
|
|
|
-// .setFunctionId(notShowChidlrenFunctionId)
|
|
|
-// .setFunctionModifyPath(notShowChildrenFunctionModifyPath);
|
|
|
-// assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction2);
|
|
|
-// }
|
|
|
- }
|
|
|
- //数据入会员和功能关联表
|
|
|
- log.info("数据插入租户会员类型和功能关联表");
|
|
|
- rows = assoTenantVipTypeFunctionMapper.insertBatch(assoTenantVipTypeAndFunctions);
|
|
|
- if (rows != assoTenantVipTypeAndFunctions.size()) {
|
|
|
- ThrowException.throwXiaoShiException("新增租户会员类型失败,数据入会员和功能关联表失败,服务器忙请稍后再试");
|
|
|
+ if (functionModifyPaths != null && !functionModifyPaths.isEmpty()) {
|
|
|
+ for (String functionModifyPath : functionModifyPaths) {
|
|
|
+ //从功能组件树路径中提取出功能id
|
|
|
+ //仁杰的方法:int functionId = Integer.parseInt(functionModifyPath.split(",")[functionModifyPath.split(",").length - 1])
|
|
|
+ int functionId = Integer.parseInt(functionModifyPath.substring(functionModifyPath.lastIndexOf(",") + 1));
|
|
|
+ //租户会员类型tenantVipTypeId、功能functionId、功能组件树路径functionModifyPath赋值给租户会员类型和功能关联表实体类
|
|
|
+ AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction = new AssoTenantVipTypeAndFunction()
|
|
|
+ .setTenantVipTypeId(tenantVipTypeId)
|
|
|
+ .setFunctionId(functionId)
|
|
|
+ .setFunctionModifyPath(functionModifyPath);
|
|
|
+ assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction);
|
|
|
+ // //根据当前功能id查询其下未展示的子级功能
|
|
|
+ // List<FunctionVO2> functionVO2s = functionMapper.selectNotShowChildrenById(functionId);
|
|
|
+ // for (FunctionVO2 functionVO2 : functionVO2s) {
|
|
|
+ // String path = functionVO2.getPath();
|
|
|
+ // Integer notShowChidlrenFunctionId = functionVO2.getId();
|
|
|
+ // Integer applicationId = functionVO2.getApplicationId();
|
|
|
+ // String notShowChildrenFunctionModifyPath = applicationId + "," + path.substring(path.indexOf(",") + 1) + "," + notShowChidlrenFunctionId;
|
|
|
+ // AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction2 = new AssoTenantVipTypeAndFunction()
|
|
|
+ // .setTenantVipTypeId(tenantVipTypeId)
|
|
|
+ // .setFunctionId(notShowChidlrenFunctionId)
|
|
|
+ // .setFunctionModifyPath(notShowChildrenFunctionModifyPath);
|
|
|
+ // assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction2);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ //数据入会员和功能关联表
|
|
|
+ log.info("数据插入租户会员类型和功能关联表");
|
|
|
+ rows = assoTenantVipTypeFunctionMapper.insertBatch(assoTenantVipTypeAndFunctions);
|
|
|
+ if (rows != assoTenantVipTypeAndFunctions.size()) {
|
|
|
+ ThrowException.throwXiaoShiException("新增租户会员类型失败,数据入会员和功能关联表失败,服务器忙请稍后再试");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
log.info("新增租户会员类型完成");
|
|
|
-
|
|
|
+ return tenantVipTypeId;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -210,39 +208,40 @@ public class TenantVipTypeService extends ServiceImpl<TenantVipTypeMapper, Tenan
|
|
|
//新数据入会员和功能关联表
|
|
|
List<AssoTenantVipTypeAndFunction> assoTenantVipTypeAndFunctions = new ArrayList<>();
|
|
|
List<String> functionModifyPaths = tenantVipTypeFunctionUpdateDTO.getFunctionModifyPaths();
|
|
|
- for (String functionModifyPath : functionModifyPaths) {
|
|
|
- //按逗号拆分路径,取拆分后的String[]中最后一个元素,将该元素转换为Integer类型
|
|
|
- //我的方法:↓
|
|
|
- //String functionStringId = functionModifyPath.substring(functionModifyPath.lastIndexOf(",") + 1);
|
|
|
- //int functionId = Integer.parseInt(functionStringId);
|
|
|
- //仁杰方法:↓
|
|
|
- String functionStringId = functionModifyPath.split(",")[functionModifyPath.split(",").length - 1];
|
|
|
- int functionId = Integer.parseInt(functionStringId);
|
|
|
- AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction = new AssoTenantVipTypeAndFunction()
|
|
|
- .setTenantVipTypeId(tenantVipTypeId)
|
|
|
- .setFunctionId(functionId)
|
|
|
- .setFunctionModifyPath(functionModifyPath);
|
|
|
- assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction);
|
|
|
-// //根据当前功能id查询其下未展示的子级功能
|
|
|
-// List<FunctionVO2> functionVO2s = functionMapper.selectNotShowChildrenById(functionId);
|
|
|
-// for (FunctionVO2 functionVO2 : functionVO2s) {
|
|
|
-// String path = functionVO2.getPath();
|
|
|
-// Integer notShowChidlrenFunctionId = functionVO2.getId();
|
|
|
-// Integer applicationId = functionVO2.getApplicationId();
|
|
|
-// String notShowChildrenFunctionModifyPath = applicationId + "," + path.substring(path.indexOf(",") + 1) + "," + notShowChidlrenFunctionId;
|
|
|
-// AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction2 = new AssoTenantVipTypeAndFunction()
|
|
|
-// .setTenantVipTypeId(tenantVipTypeId)
|
|
|
-// .setFunctionId(notShowChidlrenFunctionId)
|
|
|
-// .setFunctionModifyPath(notShowChildrenFunctionModifyPath);
|
|
|
-// assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction2);
|
|
|
-// }
|
|
|
- }
|
|
|
- log.info("新数据入会员和功能关联表");
|
|
|
- rows = assoTenantVipTypeFunctionMapper.insertBatch(assoTenantVipTypeAndFunctions);
|
|
|
- if (rows != functionModifyPaths.size()) {
|
|
|
- ThrowException.throwXiaoShiException("修改失败,新数据入会员和功能关联表失败,服务器忙请稍后再试");
|
|
|
+ if (functionModifyPaths != null && !functionModifyPaths.isEmpty()) {
|
|
|
+ for (String functionModifyPath : functionModifyPaths) {
|
|
|
+ //按逗号拆分路径,取拆分后的String[]中最后一个元素,将该元素转换为Integer类型
|
|
|
+ //我的方法:↓
|
|
|
+ //String functionStringId = functionModifyPath.substring(functionModifyPath.lastIndexOf(",") + 1);
|
|
|
+ //int functionId = Integer.parseInt(functionStringId);
|
|
|
+ //仁杰方法:↓
|
|
|
+ String functionStringId = functionModifyPath.split(",")[functionModifyPath.split(",").length - 1];
|
|
|
+ int functionId = Integer.parseInt(functionStringId);
|
|
|
+ AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction = new AssoTenantVipTypeAndFunction()
|
|
|
+ .setTenantVipTypeId(tenantVipTypeId)
|
|
|
+ .setFunctionId(functionId)
|
|
|
+ .setFunctionModifyPath(functionModifyPath);
|
|
|
+ assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction);
|
|
|
+ // //根据当前功能id查询其下未展示的子级功能
|
|
|
+ // List<FunctionVO2> functionVO2s = functionMapper.selectNotShowChildrenById(functionId);
|
|
|
+ // for (FunctionVO2 functionVO2 : functionVO2s) {
|
|
|
+ // String path = functionVO2.getPath();
|
|
|
+ // Integer notShowChidlrenFunctionId = functionVO2.getId();
|
|
|
+ // Integer applicationId = functionVO2.getApplicationId();
|
|
|
+ // String notShowChildrenFunctionModifyPath = applicationId + "," + path.substring(path.indexOf(",") + 1) + "," + notShowChidlrenFunctionId;
|
|
|
+ // AssoTenantVipTypeAndFunction assoTenantVipTypeAndFunction2 = new AssoTenantVipTypeAndFunction()
|
|
|
+ // .setTenantVipTypeId(tenantVipTypeId)
|
|
|
+ // .setFunctionId(notShowChidlrenFunctionId)
|
|
|
+ // .setFunctionModifyPath(notShowChildrenFunctionModifyPath);
|
|
|
+ // assoTenantVipTypeAndFunctions.add(assoTenantVipTypeAndFunction2);
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ log.info("新数据入会员和功能关联表");
|
|
|
+ rows = assoTenantVipTypeFunctionMapper.insertBatch(assoTenantVipTypeAndFunctions);
|
|
|
+ if (rows != functionModifyPaths.size()) {
|
|
|
+ ThrowException.throwXiaoShiException("修改失败,新数据入会员和功能关联表失败,服务器忙请稍后再试");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
log.info("修改租户会员类型完成");
|
|
|
|
|
|
}
|
|
@@ -283,4 +282,5 @@ public class TenantVipTypeService extends ServiceImpl<TenantVipTypeMapper, Tenan
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|