增加配置属性
This commit is contained in:
parent
16e25da984
commit
02ba8fc45b
|
|
@ -48,6 +48,8 @@ public class TreeNode {
|
|||
|
||||
private String remark;
|
||||
|
||||
private List<String> propertyNames;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
private List<TreeNode> children = new ArrayList<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,19 @@ import com.bonus.common.core.web.domain.AjaxResult;
|
|||
import com.bonus.material.device.domain.vo.DevInfoVo;
|
||||
import com.bonus.material.home.mapper.MaTypeInfoMapper;
|
||||
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 org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -23,6 +29,9 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
|
|||
@Resource
|
||||
private MaTypeInfoMapper maTypeInfoMapper;
|
||||
|
||||
@Resource
|
||||
private MaTypeMapper maTypeMapper;
|
||||
|
||||
/**
|
||||
* 首页查询分类树
|
||||
* @return
|
||||
|
|
@ -33,6 +42,8 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
|
|||
List<TreeNode> list = new ArrayList<>();
|
||||
try {
|
||||
list = maTypeInfoMapper.getMaTypeInfoList(typeInfo);
|
||||
//填充自定义属性
|
||||
fillProperties(list);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 创建树形结构(数据集合作为参数)
|
||||
TreeBuild treeBuild = new TreeBuild(list);
|
||||
|
|
@ -45,6 +56,20 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -379,8 +379,6 @@ public class MaTypeServiceImpl implements ITypeService {
|
|||
@Override
|
||||
public List<MaType> getEquipmentType(Long typeId, String typeName) {
|
||||
List<MaType> maTypes = maTypeMapper.selectMaTypeList("");
|
||||
//填充自定义属性
|
||||
fillProperties(maTypes);
|
||||
List<MaType> list = new ArrayList<>();
|
||||
for (MaType maType : maTypes) {
|
||||
if (maType.getParentId() == 0) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue