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.Esb2QunjieFinshSealApplyUtil;
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.Map;

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

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

        String applyId = (String) params.get("applyId");
//        String sealId = (String) params.get("sealId");
        log.error("applyId:{}",applyId);
//        log.error("sealId:{}",sealId);

        if(StringUtils.isBlank(applyId)){
            return WeaResult.fail(500,"用印申请流程获取失败");
        }

//        if(StringUtils.isBlank(sealId)){
//            return WeaResult.fail(500,"印章信息获取失败");
//        }

        String message = esb2QunjieFinshSealApplyUtil.finshApplyRquest(applyId);
        if(StringUtils.isBlank(message)){
            return WeaResult.fail(500,"关闭授权失败");
        }

        Map<String, Object> actionMap = new HashMap<String, Object>();
        actionMap.put("code",200);
        actionMap.put("msg","关闭授权成功");
        actionMap.put("data",message);

        return WeaResult.success(actionMap);
    }

}
