package com.gic.haoban.manage.service.util;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApolloUtils {

    private static final Logger log = LoggerFactory.getLogger(ApolloUtils.class);

    /**
     * 旧的调用发送，是否采用新的消息中心开关1：是 0：否
     * @return
     */
    public static boolean useMessageCenter() {
        Config config = ConfigService.getConfig("COMMON.gic-properties");
        String messageCenterSwitch = config.getProperty("messageCenterSwitch", "0");
        return "1".equals(messageCenterSwitch);
    }

    /**
     * 分享朋友圈压缩开关
     * @return
     */
    public static boolean compressShareEid(String wxEnterpriseId) {
        Config config = ConfigService.getAppConfig();
        String compressShareEid = config.getProperty("compressShareEid", "");
        if (StringUtils.isBlank(compressShareEid)) {
            return true;
        }
        boolean contains = compressShareEid.contains(wxEnterpriseId);
        log.info("分享朋友圈压缩开关:{}", contains);
        return contains;
    }

    /**
     * 导购通知一批次间隔时间
     * @return
     */
    public static Integer notifyBatchInterval() {
        Config config = ConfigService.getAppConfig();
        String notifyBatchInterval = config.getProperty("notifyBatchInterval", "60");
        log.info("导购通知一批次间隔时间:{}", notifyBatchInterval);
        return Integer.parseInt(notifyBatchInterval);
    }
}
