2023-04-21 13:23:33 +08:00
|
|
|
package com.njcn.influx.config;
|
|
|
|
|
|
|
|
|
|
import com.njcn.influx.base.ProxyMapperRegister;
|
|
|
|
|
import com.njcn.influx.core.InfluxExecutor;
|
|
|
|
|
import org.influxdb.InfluxDB;
|
|
|
|
|
import org.influxdb.impl.InfluxDBMapper;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.core.io.ResourceLoader;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author hongawen
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
*/
|
|
|
|
|
@Configuration
|
|
|
|
|
public class InfluxDbConfig {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* influxMapper存放路径
|
|
|
|
|
*/
|
|
|
|
|
@Value("${spring.influx.mapper-location}")
|
|
|
|
|
private String mapperLocation;
|
|
|
|
|
|
2023-04-25 10:23:43 +08:00
|
|
|
@Value("${spring.influx.database}")
|
|
|
|
|
private String database;
|
|
|
|
|
|
2023-04-21 13:23:33 +08:00
|
|
|
@Bean(name = "influxDbMapper")
|
2023-04-25 10:23:43 +08:00
|
|
|
public InfluxDBMapper influxDbMapper(InfluxDB influxDb) {
|
2023-04-21 13:23:33 +08:00
|
|
|
influxDb.setLogLevel(InfluxDB.LogLevel.BASIC);
|
|
|
|
|
return new InfluxDBMapper(influxDb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean(name = "influxDbExecutor")
|
|
|
|
|
public InfluxExecutor executor(InfluxDB influxDb, InfluxDBMapper influxDbMapper) {
|
2023-04-25 10:23:43 +08:00
|
|
|
return new InfluxExecutor(influxDb, influxDbMapper,database);
|
2023-04-21 13:23:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean(name = "proxyMapperRegister")
|
|
|
|
|
public ProxyMapperRegister proxyMapperRegister(ConfigurableApplicationContext applicationContext, ResourceLoader resourceLoader) {
|
|
|
|
|
return new ProxyMapperRegister(mapperLocation, applicationContext, resourceLoader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|