|
|
@@ -7,6 +7,7 @@ import com.ruoyi.platform.service.ComponentService; |
|
|
import com.ruoyi.platform.mapper.ComponentDao; |
|
|
import com.ruoyi.platform.mapper.ComponentDao; |
|
|
import com.ruoyi.platform.utils.ConvertUtil; |
|
|
import com.ruoyi.platform.utils.ConvertUtil; |
|
|
import com.ruoyi.platform.vo.ComponentVo; |
|
|
import com.ruoyi.platform.vo.ComponentVo; |
|
|
|
|
|
import com.ruoyi.system.api.domain.SysDictData; |
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
@@ -51,18 +52,22 @@ public class ComponentServiceImpl implements ComponentService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<Map> queryAllGroupedByCategory() { |
|
|
|
|
|
|
|
|
public List<Map> queryAllGroupedByCategory() throws Exception { |
|
|
List<Component> componentList = this.componentDao.queryAll(); |
|
|
List<Component> componentList = this.componentDao.queryAll(); |
|
|
List<Map> result = new ArrayList<>(); |
|
|
List<Map> result = new ArrayList<>(); |
|
|
if (componentList.isEmpty()){ |
|
|
if (componentList.isEmpty()){ |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
List<SysDictData> categoryTypeList = DictUtils.getDictCache("category_type"); |
|
|
Map<Integer,List<Component>> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); |
|
|
Map<Integer,List<Component>> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); |
|
|
for (Map.Entry <Integer,List<Component>> entry : groupedComponent.entrySet()) { |
|
|
for (Map.Entry <Integer,List<Component>> entry : groupedComponent.entrySet()) { |
|
|
String name = DictUtils.getCacheKey(String.valueOf(entry.getKey())); |
|
|
|
|
|
|
|
|
List<SysDictData> categorys = categoryTypeList.stream().filter(sysDictData -> StringUtils.equals(sysDictData.getDictValue(), String.valueOf(entry.getKey()))).collect(Collectors.toList()); |
|
|
|
|
|
if (categorys.size() ==0){ |
|
|
|
|
|
throw new Exception("组件类型不存在"); |
|
|
|
|
|
} |
|
|
Map map = new HashMap(); |
|
|
Map map = new HashMap(); |
|
|
map.put("key", entry.getKey()); |
|
|
map.put("key", entry.getKey()); |
|
|
map.put("name", name); |
|
|
|
|
|
|
|
|
map.put("name", categorys.get(0).getDictLabel()); |
|
|
map.put("value", entry.getValue()); |
|
|
map.put("value", entry.getValue()); |
|
|
result.add(map); |
|
|
result.add(map); |
|
|
} |
|
|
} |
|
|
|