|
@@ -11,11 +11,14 @@ import com.pavis.app.saasbacken.entity.CheckModule;
|
|
|
import com.pavis.app.saasbacken.entity.InitDataChild;
|
|
|
import com.pavis.app.saasbacken.entity.InitDataParent;
|
|
|
import com.pavis.app.saasbacken.entity.InitDataThird;
|
|
|
+import com.pavis.app.saasbacken.exception.IllegalArgumentException;
|
|
|
import com.pavis.app.saasbacken.form.ModuleData;
|
|
|
import com.pavis.app.saasbacken.form.ModuleParam;
|
|
|
import com.pavis.app.saasbacken.form.ModuleTree;
|
|
|
+import com.pavis.app.saasbacken.http.ErrorCode;
|
|
|
import com.pavis.app.saasbacken.service.CheckModuleService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -23,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -95,7 +99,15 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
|
|
|
@Override
|
|
|
public List<CheckModule> addInitData(List<ModuleTree> moduleTrees) {
|
|
|
+ List<CheckModule> checkModules = checkModuleMapper.selectList(new QueryWrapper<CheckModule>().lambda().isNotNull(CheckModule::getId));
|
|
|
+ if (checkModules.size() > 0){
|
|
|
+ // 先删除,后新增。
|
|
|
+ List<String> ids = checkModules.stream().map(t -> t.getId()).collect(Collectors.toList());
|
|
|
+ int i = checkModuleMapper.deleteBatchIds(ids);
|
|
|
+ log.info("del res:{}",i);
|
|
|
+ }
|
|
|
|
|
|
+ // 一级数据
|
|
|
CheckModule firstCheck;
|
|
|
List<CheckModule> firstCheckModules = new ArrayList<>();
|
|
|
List<CheckModule> thirdCheckModules = new ArrayList<>();
|
|
@@ -107,6 +119,7 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
firstCheck.setParentId("0");
|
|
|
firstCheckModules.add(firstCheck);
|
|
|
|
|
|
+ // 二级数据
|
|
|
CheckModule secCheck;
|
|
|
for (ModuleParam tree : moduleTree.getTrees()) {
|
|
|
secCheck = new CheckModule();
|
|
@@ -114,6 +127,7 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
secCheck.setResType(tree.getId());
|
|
|
secCheckModules.add(secCheck);
|
|
|
|
|
|
+ // 三级数据
|
|
|
CheckModule thirdCheck;
|
|
|
for (ModuleData treeTree : tree.getTrees()) {
|
|
|
thirdCheck = new CheckModule();
|
|
@@ -129,23 +143,6 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
log.info("secCheckModules:{}",JSON.toJSONString(secCheckModules));
|
|
|
log.info("thirdCheckModules:{}",JSON.toJSONString(thirdCheckModules));
|
|
|
|
|
|
- // 增删改查。
|
|
|
- // 提交的数据结构。
|
|
|
- // 返回的数据结构
|
|
|
- CheckModule checkModule = CheckModule.builder()
|
|
|
- .resType("")
|
|
|
- .title("")
|
|
|
- .titleCode("")
|
|
|
- .parentId("")
|
|
|
- .icon("")
|
|
|
- .isEnabled("")
|
|
|
- .isMust("")
|
|
|
- .isSorted("")
|
|
|
- .weatherChild("")
|
|
|
- .showType("")
|
|
|
- .build();
|
|
|
- // 是否必填,手动设置。还是前端展示,节点管理员可选。
|
|
|
-
|
|
|
boolean b = saveBatch(firstCheckModules);
|
|
|
boolean b1 = saveBatch(secCheckModules);
|
|
|
boolean b2 = saveBatch(thirdCheckModules);
|
|
@@ -153,20 +150,31 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
log.info("b1:{}",b1);
|
|
|
log.info("b2:{}",b2);
|
|
|
|
|
|
- List<CheckModule> checkModules = checkModuleMapper.selectList(new QueryWrapper<CheckModule>().lambda().isNotNull(CheckModule::getId));
|
|
|
return checkModules;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<ModuleParam> getNodeData() {
|
|
|
+ public List<ModuleParam> getNodeData(String resType) {
|
|
|
+ if (StringUtils.isEmpty(resType)){
|
|
|
+ throw new IllegalArgumentException(ErrorCode.ILLEGAL_ARGUMENT.getCode(), ErrorCode.ILLEGAL_ARGUMENT.getMessage());
|
|
|
+ }
|
|
|
+ // 根据resType值判断是什么资源库的数据,如果resType为-1则表示获取所有资源库的层级数据。
|
|
|
+ List<CheckModule> checkModules1 = new ArrayList<>();
|
|
|
+ if ("-1".equals(resType)){
|
|
|
+ checkModules1 = checkModuleMapper.selectList(new QueryWrapper<CheckModule>().lambda().eq(CheckModule::getParentId,"0"));
|
|
|
+ }else {
|
|
|
+ checkModules1 = checkModuleMapper.selectList(new QueryWrapper<CheckModule>().lambda()
|
|
|
+ .eq(CheckModule::getResType,resType)
|
|
|
+ .eq(CheckModule::getParentId,"0"));
|
|
|
+ }
|
|
|
// 构建返回信息。
|
|
|
- List<CheckModule> checkModules1 = checkModuleMapper.selectList(new QueryWrapper<CheckModule>().lambda().eq(CheckModule::getParentId,"0"));
|
|
|
ModuleParam moduleParam;
|
|
|
List<ModuleParam> moduleParams = new ArrayList<>();
|
|
|
for (CheckModule module : checkModules1) {
|
|
|
moduleParam = new ModuleParam();
|
|
|
BeanUtils.copyProperties(module, moduleParam);
|
|
|
|
|
|
+ // 二级
|
|
|
List<ModuleData> childs = new ArrayList<>();
|
|
|
ModuleParam moduleParamChild;
|
|
|
List<CheckModule> checkModules2 = checkModuleMapper.selectList(new QueryWrapper<CheckModule>()
|
|
@@ -176,6 +184,7 @@ public class CheckModuleServiceImpl extends ServiceImpl<CheckModuleMapper, Check
|
|
|
BeanUtils.copyProperties(checkModule1, moduleParamChild);
|
|
|
childs.add(moduleParamChild);
|
|
|
|
|
|
+ // 三级
|
|
|
ModuleParam moduleParamThird;
|
|
|
List<ModuleData> thirds = new ArrayList<>();
|
|
|
List<CheckModule> checkModules3 = checkModuleMapper.selectList(new QueryWrapper<CheckModule>()
|