Files
happy-life-star/server/src/main/java/com/emotionmuseum/config/CozeConfig.java
T

64 lines
1.4 KiB
Java

package com.emotionmuseum.config;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import jakarta.annotation.PostConstruct;
/**
* Coze配置类
*
* @author emotion-museum
* @version 1.0.0
* @since 2024-01-01
*/
@Configuration
@ConfigurationProperties(prefix = "emotion.coze")
@Data
@Slf4j
public class CozeConfig {
/**
* API密钥
*/
private String apiKey;
/**
* 机器人ID
*/
private String botId;
/**
* 基础URL
*/
private String baseUrl = "https://www.coze.cn/api";
/**
* 超时时间(毫秒)
*/
private int timeout = 30000;
/**
* 最大重试次数
*/
private int maxRetries = 3;
/**
* 验证配置
*/
@PostConstruct
public void validateConfig() {
if (!StringUtils.hasText(apiKey)) {
log.warn("Coze API Key未配置,AI功能可能无法正常使用");
}
if (!StringUtils.hasText(botId)) {
log.warn("Coze Bot ID未配置,AI功能可能无法正常使用");
}
if (StringUtils.hasText(apiKey) && StringUtils.hasText(botId)) {
log.info("Coze配置验证通过,Bot ID: {}", botId);
}
}
}