package com.changhu.common.properties;

import com.changhu.common.exception.MessageException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * author: luozhun
 * desc: some...
 * createTime: 2023/11/29 15:42
 */
@Slf4j
@Data
@Component
@ConfigurationProperties(prefix = "project")
public class ProjectProperties {
    /**
     * 项目运行环境
     */
    private ProjectEnv env;

    @Bean
    public ProjectEnv projectEnv() {
        if (env == null) {
            throw new MessageException("当前环境没有配置【projectEnv】请配置");
        }
        log.info("当前运行环境:【{} ({})】", env.getValue(), env.getLabel());
        return env;
    }
}
