package com.hz.pm.api.expert.assembler;

import cn.hutool.core.collection.CollUtil;
import com.hz.pm.api.expert.model.DictFieldInfoDTO;
import com.hz.pm.api.meta.model.entity.ExpertDictionary;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liuxinxin
 * @date 2022/7/25 下午4:30
 */
public class DictAssembler {

    private DictAssembler() {
    }

    public static List<DictFieldInfoDTO> convert(List<ExpertDictionary> expertDictList) {
        if (CollUtil.isEmpty(expertDictList)) {
            return Collections.emptyList();
        }
        return expertDictList.stream().map(r -> {
            DictFieldInfoDTO dictionaryFieldInfo = new DictFieldInfoDTO();
            dictionaryFieldInfo.setDictionaryFieldName(r.getExpertInfoField());
            dictionaryFieldInfo.setDictionaryCode(r.getDictionaryCode());
            return dictionaryFieldInfo;
        }).collect(Collectors.toList());
    }
}
