package com.ningdatech.pmapi.expert.assembler;

import cn.hutool.core.collection.CollUtil;
import com.ningdatech.pmapi.expert.model.DictionaryFieldInfo;
import com.ningdatech.pmapi.meta.model.entity.ExpertDictionary;

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

/**
 * @author liuxinxin
 * @date 2022/7/25 下午4:30
 */

public class DictionaryAssembler {

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