| | |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(categoryList)){ |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode() |
| | | +systemDictDataBiz.queryByCode(Constants.OSS,Constants.CATEGORY_FILES).getCode(); |
| | | // 收集非空的 relationId 批量查询 |
| | | java.util.Set<Integer> relationIds = new java.util.HashSet<>(); |
| | | for (Category category : categoryList) { |
| | | if (category.getRelationId() != null) { |
| | | relationIds.add(category.getRelationId()); |
| | | } |
| | | } |
| | | java.util.Map<Integer, String> relationNameMap = new java.util.HashMap<>(); |
| | | java.util.Map<Integer, String> relationOtherFieldMap = new java.util.HashMap<>(); |
| | | java.util.Map<Integer, String> relationRemarkMap = new java.util.HashMap<>(); |
| | | if (!relationIds.isEmpty()) { |
| | | categoryMapper.selectList(new QueryWrapper<Category>().lambda() |
| | | .in(Category::getId, relationIds) |
| | | .eq(Category::getDeleted, Constants.ZERO)) |
| | | .forEach(c -> { |
| | | relationNameMap.put(c.getId(), c.getName()); |
| | | relationOtherFieldMap.put(c.getId(), c.getOtherField()); |
| | | relationRemarkMap.put(c.getId(), c.getRemark()); |
| | | }); |
| | | } |
| | | for (Category category:categoryList) { |
| | | if(StringUtils.isNotBlank(category.getIcon())){ |
| | | category.setIconFull(path + category.getIcon()); |
| | | } |
| | | if (category.getRelationId() != null) { |
| | | category.setRelationName(relationNameMap.get(category.getRelationId())); |
| | | category.setRelationOtherField(relationOtherFieldMap.get(category.getRelationId())); |
| | | category.setRelationRemark(relationRemarkMap.get(category.getRelationId())); |
| | | } |
| | | } |
| | | } |
| | |
| | | .orderByAsc(Category::getSortnum)); |
| | | // 3. 拼接图标全路径 |
| | | if (!CollectionUtils.isEmpty(sizeList)) { |
| | | String path = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.RESOURCE_PATH).getCode() |
| | | String path = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.OSS, Constants.CATEGORY_FILES).getCode(); |
| | | for (Category cate : sizeList) { |
| | | if (StringUtils.isNotBlank(cate.getIcon())) { |