package com.lightinit.hsdataplatformresdir.common;

import com.lightinit.hsdataplatformresdir.dictionary.DicNewGateway;

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

public class GateWayUtils {

    public static String gatewayAuthAdd(String ouyId1, String applicationid, String userId, String remark) {
        String code = null ;
        Map<String, String> params = new HashMap<>();
        params.put("routeId", ouyId1);
        params.put("appId", applicationid);
        params.put("userId", userId);
        params.put("remark", remark);
        try {
            String str = HttpUtil.httpPost(DicNewGateway.AUTHADD, null, params);
            Map<String, Object> map1 = HttpUtil.strToMap(str);
            if (map1.get("code").equals("200")) {
                code = map1.get("code").toString() ;
            }else {
                throw new RuntimeException("新增api鉴权异常:"+map1.get("message"));
            }
            System.out.println("=================" + map1 + "==========================");
        } catch (Exception e) {
            throw new RuntimeException("新增api鉴权异常!");
        }
        return code ;
    }

    public static String gatewayChargeAdd(String ouyId1, String applicationid, String userId,String chargeType
            ,String chargeValue, String remark) {
        String code = null ;
        Map<String, String> params = new HashMap<>();
        params.put("routeId", ouyId1);
        params.put("applicationId", applicationid);
        params.put("userId", userId);
        params.put("chargeType", chargeType);
        params.put("chargeValue", chargeValue);
        params.put("effectiveTime", new Date().toString());
        params.put("remark", remark);
        try {
            String str = HttpUtil.httpPost(DicNewGateway.CHANGEADD, null, params);
            Map<String, Object> map1 = HttpUtil.strToMap(str);
            if (map1.get("code").equals("200")) {
                code = map1.get("code").toString() ;
            } else {
                throw new RuntimeException("新增api鉴权异常:"+map1.get("message"));
            }
            System.out.println("=================" + map1 + "==========================");
        } catch (Exception e) {
            throw new RuntimeException("新增api计费异常！");
        }
        return code ;
    }

}
