package com.xjrsoft.module.liteflow.node;

import java.util.Map;
import java.util.Optional;

public class util {

    /**
     * 获取表单主键
     *
     * @return
     */
    public static Object getFormDatKey(Map<String, Object> params,String key) {
        Map<String, Object> formData = getFormData(params);
        if (formData != null) {
           return  formData.get(key);
        }
        return null;
    }

    /**
     * 获取表单数据
     *
     * @param params
     * @return
     */
    public static Map<String, Object> getFormData(Map<String, Object> params) {
        Optional<String> formKey = params.keySet().stream().filter(f -> f.contains("form_")).findFirst();
        if (formKey.isPresent()) {
            return (Map<String, Object>) params.get(formKey.get());
        }
        return null;
    }
}
