package com.vci.ubcs.omd.wrapper;
|
|
import com.vci.ubcs.omd.entity.Attribute;
|
import com.vci.ubcs.omd.vo.*;
|
import com.vci.ubcs.system.cache.DictBizCache;
|
import org.springblade.core.mp.support.BaseEntityWrapper;
|
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.StringUtil;
|
|
import java.util.List;
|
import java.util.Objects;
|
import java.util.stream.Collectors;
|
|
|
/**
|
* 元数据对象的包装类,返回视图层所需的字段
|
*
|
* @author LiHang
|
* @date 2023/4/3
|
*/
|
public class AttributeWrapper extends BaseEntityWrapper<Attribute, AttributeVO> {
|
|
public static AttributeWrapper build() {
|
return new AttributeWrapper();
|
}
|
|
/**
|
* do2vo
|
* @param entity pojo
|
* @return 显示对象
|
*/
|
@Override
|
public AttributeVO entityVO(Attribute entity) {
|
AttributeVO vo = Objects.requireNonNull(BeanUtil.copy(entity, AttributeVO.class));
|
vo.setTypeValue(DictBizCache.getValue(vo.getTypeCode(),vo.getTypeKey()));
|
if (StringUtil.isNotBlank(vo.getReferTypeCode())){
|
vo.setReferTypeValue(DictBizCache.getValue(vo.getReferTypeCode(),vo.getReferTypeKey()));
|
}
|
if (StringUtil.isNotBlank(vo.getDictCode())){
|
vo.setDictValue(DictBizCache.getValue(vo.getDictCode(),vo.getDictKey()));
|
}
|
return vo;
|
}
|
|
/**
|
* 批量转vo
|
* @param list pojo集合
|
* @return 显示对象
|
*/
|
public List<AttributeVO> listEntityVO(List<Attribute> list) {
|
return list.stream().map(this::entityVO).collect(Collectors.toList());
|
}
|
}
|