package cn.stylefeng.workflow.instance.modular.export.factory;

import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.team.form.api.entity.FormItem;
import cn.stylefeng.team.form.api.pojo.FormDesignVo;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class ExportInstanceFactory {

    public static Map<String, FormItem> getFormItemMap(List<FormDesignVo> formDesignVoList) {

        Map<String, FormItem> resultMap = new LinkedHashMap<>();

        if (ObjectUtil.isEmpty(formDesignVoList)) {
            return resultMap;
        }

        for (FormDesignVo formDesignVo : formDesignVoList) {
            List<FormItem> formItemList = formDesignVo.getFormItemList();
            if (ObjectUtil.isNotEmpty(formItemList)) {
                for (FormItem formItem : formItemList) {
                    resultMap.put(formItem.getFieldCode(), formItem);
                }
            }
        }

        return resultMap;
    }

}
