diff --git a/src/main/java/com/supervision/police/service/impl/ComDictionaryServiceImpl.java b/src/main/java/com/supervision/police/service/impl/ComDictionaryServiceImpl.java index fe38919..e67a7b8 100644 --- a/src/main/java/com/supervision/police/service/impl/ComDictionaryServiceImpl.java +++ b/src/main/java/com/supervision/police/service/impl/ComDictionaryServiceImpl.java @@ -1,5 +1,6 @@ package com.supervision.police.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -68,30 +69,33 @@ public class ComDictionaryServiceImpl extends ServiceImpl> queryDictionary(DictionaryByTypeParam dictionaryByTypeParam) { Map> resultMap = new HashMap<>(); - List typeList = new ArrayList<>(); - if (dictionaryByTypeParam.getList() == null || dictionaryByTypeParam.getList().size() <=0) { - typeList = comDictionaryMapper.queryAllType(); - } else { - typeList = dictionaryByTypeParam.getList(); - } + + List typeList = CollUtil.isEmpty(dictionaryByTypeParam.getList()) ? + comDictionaryMapper.queryAllType() : dictionaryByTypeParam.getList(); + for (String dictType : typeList) { - List queryList = new ArrayList<>(); + List queryList; List otherList = new ArrayList<>(); ComDictionary comDictionary = new ComDictionary(); comDictionary.setType(dictType); Wrapper wrapper = Wrappers.query(comDictionary); queryList = this.comDictionaryMapper.selectList(wrapper); changeTree(queryList,otherList); - if (otherList.size() > 1) { - if (dictionaryByTypeParam.getIsTree() != null && dictionaryByTypeParam.getIsTree() == 0) { + + if (CollUtil.size(otherList) > 1) { + // 平铺数据 + if (Integer.valueOf(0).equals(dictionaryByTypeParam.getIsTree())) { resultMap.put(dictType,queryList); }else { + // 树形数据 resultMap.put(dictType,otherList); } } else { - if (dictionaryByTypeParam.getIsTree() != null && dictionaryByTypeParam.getIsTree() == 0){ + // 平铺数据 + if (Integer.valueOf(0).equals(dictionaryByTypeParam.getIsTree())){ resultMap.put(dictType,otherList.get(0).getChild()); }else { + // 树形数据 resultMap.put(dictType,otherList); } } @@ -129,7 +133,7 @@ public class ComDictionaryServiceImpl extends ServiceImpl