All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hp.message.config.ApiAutoConfigure Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
package com.hp.message.config;

import com.hp.message.interfaces.IRetrofitApiService;
import com.hp.message.property.ApiProperty;
import com.hp.message.interfaces.IApiService;
import com.hp.message.service.ApiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author 尚肖磊
 * @create 2021-06-18 16:01
 * @Description: api服务自动配置类
 */
@Slf4j
@Configuration
@ComponentScan("com.hp.message.interfaces")
@ComponentScan("com.hp.message.service.common")
@ComponentScan("com.hp.message.service.event")
@AutoConfigureAfter(AppAutoConfigure.class)
@EnableConfigurationProperties(value = ApiProperty.class)
public class ApiAutoConfigure {

    /**
     * 华普api接口配置类
     */
    private final ApiProperty apiProperty;

    @Autowired
    private IRetrofitApiService retrofitApiService;

    public ApiAutoConfigure(ApiProperty apiProperty) {
        if (apiProperty == null){
            log.error( "{} config lost", ApiProperty.DEFAULT_PREFIX);
        }
        this.apiProperty = apiProperty;
    }

    @Bean
    @ConditionalOnMissingBean
    public IApiService createApiService(){
        return new ApiService(retrofitApiService);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy