package org.jeecg.modules.stm.utils;

import org.jeecg.common.util.SpringContextUtils;
import org.jeecg.modules.stm.base.lable.service.IStLableService;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author: yzh
 * @Date 2023/4/9 12:30
 * @Description:
 */
public class QueryLableParamsUtlis {

    private static String getLableName(Map<String, String[]> parameterMap){
       String [] param = parameterMap.get("lableName");
       if(param!=null && param.length==1){
           return param[0];
       }
       return null;
    }

    private static List<String> getLableCodesList(Map<String, String[]> parameterMap){
        String [] param = parameterMap.get("lableCodes[]");
        if(param!=null && param.length>0){
            return Arrays.asList(param);
        }
        return null;
    }

    private static List<String> getClassifyCodes(Map<String, String[]> parameterMap){
        String [] param = parameterMap.get("checkClassFiy[]");
        if(param!=null && param.length>0){
            return Arrays.asList(param);
        }
        return null;
    }

    public static List<String> getLableCodes(Map<String, String[]>  parameterMap){
        IStLableService iStLableService = SpringContextUtils.getBean(IStLableService.class);
        return iStLableService.getCodes(getLableName(parameterMap),getLableCodesList(parameterMap),getClassifyCodes(parameterMap));
    }
}
