lihang
2023-04-17 7b157aa56608423c9e7de63e12240e8044b3afd9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.vci.ubcs.omd.wrapper;
 
import com.vci.ubcs.omd.cache.DictBizCache;
import com.vci.ubcs.omd.entity.OmdAttribute;
import com.vci.ubcs.omd.vo.*;
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<OmdAttribute, OmdAttributeVO> {
 
    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<OmdAttributeVO> listEntityVO(List<OmdAttribute> list) {
        return list.stream().map(this::entityVO).collect(Collectors.toList());
    }
}