package com.friday.tooldriver.service.rpa.supplier.smartrpa;

import com.friday.base.common.response.DubboResult;
import com.friday.operation.api.tooldriver.service.IEnvironment;
import com.friday.tooldriver.utils.SM2Utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class EnvironmentManager implements IEnvironment {

    @Value("${smartRPA.dev.url}")
    private String devUrl;

    @Value("${smartRPA.sit.url}")
    private String sitUrl;

    @Value("${smartRPA.rc.url}")
    private String rcUrl;

    @Value("${smartRPA.prod.url}")
    private String prodUrl;

    @Override
    public DubboResult<String> queryEnvInfo(String env) {
        String result = "";
        switch (env){
            case "dev" : result = devUrl;
            break;
            case "sit" : result = sitUrl;
            break;
            case "rc" : result = rcUrl;
            break;
            case "prod" : result = prodUrl;
        }

        /*log.info(SM2Utils.getSM4decrypt(SM2Utils.getSM4encrypt(result)));*/
        return DubboResult.newSuccess(SM2Utils.getSM4encrypt(result));
    }
}
