增加配置属性

This commit is contained in:
sxu 2024-12-10 12:07:06 +08:00
parent 16e25da984
commit 02ba8fc45b
3 changed files with 27 additions and 2 deletions

View File

@ -48,6 +48,8 @@ public class TreeNode {
private String remark; private String remark;
private List<String> propertyNames;
@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeNode> children = new ArrayList<>(); private List<TreeNode> children = new ArrayList<>();
} }

View File

@ -8,13 +8,19 @@ import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.device.domain.vo.DevInfoVo; import com.bonus.material.device.domain.vo.DevInfoVo;
import com.bonus.material.home.mapper.MaTypeInfoMapper; import com.bonus.material.home.mapper.MaTypeInfoMapper;
import com.bonus.material.home.service.MaTypeInfoSevice; import com.bonus.material.home.service.MaTypeInfoSevice;
import com.bonus.material.ma.mapper.MaTypeMapper;
import com.bonus.material.ma.vo.MaType;
import com.bonus.material.ma.vo.MaTypeProperty;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
@ -23,6 +29,9 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
@Resource @Resource
private MaTypeInfoMapper maTypeInfoMapper; private MaTypeInfoMapper maTypeInfoMapper;
@Resource
private MaTypeMapper maTypeMapper;
/** /**
* 首页查询分类树 * 首页查询分类树
* @return * @return
@ -33,6 +42,8 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
List<TreeNode> list = new ArrayList<>(); List<TreeNode> list = new ArrayList<>();
try { try {
list = maTypeInfoMapper.getMaTypeInfoList(typeInfo); list = maTypeInfoMapper.getMaTypeInfoList(typeInfo);
//填充自定义属性
fillProperties(list);
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
// 创建树形结构数据集合作为参数 // 创建树形结构数据集合作为参数
TreeBuild treeBuild = new TreeBuild(list); TreeBuild treeBuild = new TreeBuild(list);
@ -45,6 +56,20 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
return AjaxResult.success(groupList); return AjaxResult.success(groupList);
} }
private void fillProperties(List<TreeNode> treeNodes) {
List<MaTypeProperty> maTypeProperties = maTypeMapper.selectMaTypePropertyNames();
Map<Long, List<MaTypeProperty>> maTypePropertiesMap = new HashMap<>();
if (!org.springframework.util.CollectionUtils.isEmpty(maTypeProperties)) {
maTypePropertiesMap = maTypeProperties.stream().collect(Collectors.groupingBy(MaTypeProperty::getTypeId));
}
for (TreeNode treeNode : treeNodes) {
List<MaTypeProperty> tmpPropList = maTypePropertiesMap.get(treeNode.getId());
if (!org.springframework.util.CollectionUtils.isEmpty(tmpPropList)) {
treeNode.setPropertyNames(tmpPropList.stream().map(o -> o.getPropertyName()).collect(Collectors.toList()));
}
}
}
/** /**
* 首页搜索热搜装备 * 首页搜索热搜装备
* @param devInfoVo * @param devInfoVo

View File

@ -379,8 +379,6 @@ public class MaTypeServiceImpl implements ITypeService {
@Override @Override
public List<MaType> getEquipmentType(Long typeId, String typeName) { public List<MaType> getEquipmentType(Long typeId, String typeName) {
List<MaType> maTypes = maTypeMapper.selectMaTypeList(""); List<MaType> maTypes = maTypeMapper.selectMaTypeList("");
//填充自定义属性
fillProperties(maTypes);
List<MaType> list = new ArrayList<>(); List<MaType> list = new ArrayList<>();
for (MaType maType : maTypes) { for (MaType maType : maTypes) {
if (maType.getParentId() == 0) { if (maType.getParentId() == 0) {