package com.weaver.seconddev.chapanda.qunjie.esb;

import com.weaver.common.base.entity.result.WeaResult;
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
import com.weaver.seconddev.chapanda.qunjie.util.Esb2QunjieQuerySealUtil;
import com.weaver.seconddev.chapanda.qunjie.util.Esb2QunjieTokenUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("Esb2QunjieQuerySealBaseCron")
public class Esb2QunjieQuerySealBaseCron implements EsbServerlessRpcRemoteInterface {
    private final static Logger log = LoggerFactory.getLogger(Esb2QunjieQuerySealBaseCron.class);

    @Autowired
    Esb2QunjieTokenUtil esb2QunjieTokenUtil;

    @Autowired
    Esb2QunjieQuerySealUtil esb2QunjieQuerySealUtil;

    @Override
    public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
        log.error("Esb2QunjieQuerySealBaseCron start");

        String accessToken = esb2QunjieTokenUtil.getAccessToken();
        if(StringUtils.isNotBlank(accessToken)){
            List<String> ebList = esb2QunjieQuerySealUtil.querySealBaseList(accessToken);
            log.error("ebList:{}",ebList.size());
        }

        Map<String, Object> actionMap = new HashMap<String, Object>();
        actionMap.put("code",200);
        actionMap.put("msg","Esb2QunjieQuerySealBaseCron");

        return WeaResult.success(actionMap);
    }

}
