package com.qmth.teachcloud.report.business.utils;


import com.qmth.teachcloud.common.enums.ExceptionResultEnum;

import java.util.HashMap;
import java.util.Map;


public class AnalyzeScopeUtil {
    public static Map<String,Object> analyzeScope(String scope) {
        if (scope == null || scope.length() < 1) {
            throw ExceptionResultEnum.ERROR.exception("没有找到范围取值");
        }
        String tmp = scope.substring(1, scope.length() - 1);
        String[] valueArr = tmp.split(",");
        if (valueArr.length != 2){
            throw ExceptionResultEnum.ERROR.exception("范围解析异常");
        }

        String minValue = valueArr[0];
        String maxValue = valueArr[1];
        String minSign = scope.substring(0,1);
        String maxSign = scope.substring(scope.length() - 1);

        Map<String,Object> result = new HashMap<>();
        result.put("minValue",minValue);
        result.put("maxValue",maxValue);
        result.put("minSign",minSign);
        result.put("maxSign",maxSign);
        return result;
    }
}
