package com.huashe.park.infrastructure.cfg.forest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import com.dtflys.forest.annotation.BindingVar;
import com.dtflys.forest.reflection.ForestMethod;

@Component
@ConfigurationProperties(prefix = "forest.custom")
@ConditionalOnBean(UWBForestCfg.class)
public class CustomForestCfg {
    private String holiday;

    public String getHoliday() {
        return holiday;
    }

    public void setHoliday(String holiday) {
        this.holiday = holiday;
    }

    @Autowired
    private UWBForestCfg uwbForestCfg;

    @Autowired
    private CollectMqttForestCfg collectMqttForestCfg;

    @BindingVar("uwbBaseUrl")
    public String getBaseUrl(ForestMethod method) {
        return uwbForestCfg.getUwbHost();
    }

    @BindingVar("holidayBaseUrl")
    public String getHolidayBaseUrl(ForestMethod method) {
        return holiday;
    }

    @BindingVar("collectMqtt")
    public String getCadBaseUrl(ForestMethod method) {
        return collectMqttForestCfg.getUrl();
    }

}
