package com.vci.ubcs.omd.wrapper; import com.vci.ubcs.omd.entity.OmdAttribute; 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 OmdAttributeWrapper extends BaseEntityWrapper { public static OmdAttributeWrapper build() { return new OmdAttributeWrapper(); } /** * do2vo * @param entity pojo * @return 显示对象 */ @Override public OmdAttributeVO entityVO(OmdAttribute entity) { OmdAttributeVO vo = Objects.requireNonNull(BeanUtil.copy(entity, OmdAttributeVO.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 listEntityVO(List list) { return list.stream().map(this::entityVO).collect(Collectors.toList()); } }