package com.prolog.cs.biz.outbound.service.strategy.handles;

import com.prolog.cs.biz.outbound.service.strategy.STRATEGY_CODE;
import com.prolog.framework.utils.ObjectUtils;
import com.prolog.upcloud.base.strategy.model.BusinessControl;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * @program: upcloud-base-wh-outbound
 * @description: 获取业务配置参数的返回值的公用 handle
 * @author: Huanglh
 * @create: 2022-02-08 16:16
 **/
@Service
public class ResultCommonHandle extends AbstractStrategyHandle {

    public ResultCommonHandle() {
        super();
    }

    public ResultCommonHandle(String point, Map<STRATEGY_CODE, BusinessControl> businessControlMap) {
        super(point, businessControlMap);
    }

    /**
     * @param args
     */
    @Override
    public void execute(Object... args) {
        return;
    }

    /**
     * 只返回一个配置的值
     *
     * @param args
     * @return
     */
    @Override
    public Object getResult(Object... args) {
        if (ObjectUtils.isNotNull(this.businessControlMap)) {
            STRATEGY_CODE code = this.businessControlMap.keySet().stream().collect(Collectors.toList()).get(0);
            return super.getRgeValue(code, null);
        }
        return null;
    }
}
