package com.upyuns.platform.rs.gtdata;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

@Slf4j
public class GtdataCondition implements Condition {
    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Environment environment = conditionContext.getEnvironment();
        String sign = environment.getProperty("gtdata.use");
        log.info(sign == null? "null" : sign);
        if(StrUtil.isNotBlank(sign) && "true".equals(sign)){
            return true;
        }
        return false;
    }
}