You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

package com.nov.KgLowDurable.wrapper;
import com.nov.KgLowDurable.mapper.LdDictMapper;
import com.nov.KgLowDurable.pojo.entity.LdDict;
import com.nov.KgLowDurable.pojo.vo.LdDictVO;
import com.nov.KgLowDurable.util.BeanUtil;
import com.nov.KgLowDurable.util.BladeConstant;
import com.nov.KgLowDurable.util.ForestNodeMerger;
import com.nov.KgLowDurable.util.Func;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 包装类,返回视图层所需的字段
*
* @author Chill
*/
public class LdDictWrapper extends BaseEntityWrapper<LdDict, LdDictVO> {
private static final LdDictMapper ldDictMapper = null;
public static LdDictWrapper build() {
return new LdDictWrapper();
}
@Override
public LdDictVO entityVO(LdDict LdDict) {
LdDictVO LdDictVO = Objects.requireNonNull(BeanUtil.copyProperties(LdDict, LdDictVO.class));
if (Func.equals(LdDict.getParentId(), BladeConstant.TOP_PARENT_ID)) {
LdDictVO.setParentName(BladeConstant.TOP_PARENT_NAME);
} else {
LdDict parent = ldDictMapper.selectById(LdDict.getParentId());
LdDictVO.setParentName(parent.getDictValue());
}
return LdDictVO;
}
public List listNodeVO(List<LdDict> list) {
List<LdDictVO> collect = list.stream().map(LdDict -> BeanUtil.copyProperties(LdDict, LdDictVO.class)).collect(Collectors.toList());
return ForestNodeMerger.mergeDict(collect);
}
}