KeywordSource.java 2.5 KB
package com.aigeo.common.enums;

import lombok.Getter;

/**
 * 关键词来源枚举
 * 对应数据库字段:
 * - ai_keywords.source
 * - ai_keyword_expansions.source
 * - ai_topics.source
 * 
 * 关键词获取渠道:
 * - BAIDU: 百度关键词工具
 * - GOOGLE: Google关键词规划师
 * - MANUAL: 人工手动添加
 * - EXPANSION: 关键词扩展生成
 * - IMPORT: 批量导入
 *
 * @author AIGEO Team
 * @since 1.0.0
 */
@Getter
public enum KeywordSource {
    
    /**
     * 百度关键词工具 - 通过百度API获取
     */
    BAIDU("baidu", "百度关键词"),
    
    /**
     * Google关键词规划师 - 通过Google API获取
     */
    GOOGLE("google", "Google关键词"),
    
    /**
     * 手动添加 - 用户手工输入
     */
    MANUAL("manual", "手动添加"),
    
    /**
     * 关键词扩展 - 基于现有关键词扩展
     */
    EXPANSION("expansion", "关键词扩展"),
    
    /**
     * 批量导入 - 从文件或其他系统导入
     */
    IMPORT("import", "批量导入");

    /**
     * 数据库存储值
     */
    private final String code;
    
    /**
     * 显示名称
     */
    private final String displayName;

    KeywordSource(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static KeywordSource fromCode(String code) {
        for (KeywordSource source : values()) {
            if (source.code.equals(code)) {
                return source;
            }
        }
        throw new IllegalArgumentException("未知的关键词来源代码: " + code);
    }
    
    /**
     * 检查是否为自动获取
     */
    public boolean isAutomaticSource() {
        return this == BAIDU || this == GOOGLE || this == EXPANSION;
    }
    
    /**
     * 检查是否需要API调用
     */
    public boolean requiresApiCall() {
        return this == BAIDU || this == GOOGLE;
    }
    
    /**
     * 检查是否支持批量操作
     */
    public boolean supportsBatchOperation() {
        return this == IMPORT || this == EXPANSION;
    }
    
    /**
     * 获取数据可靠性评分(1-5分)
     */
    public int getReliabilityScore() {
        switch (this) {
            case GOOGLE:
                return 5;
            case BAIDU:
                return 4;
            case EXPANSION:
                return 3;
            case IMPORT:
                return 2;
            case MANUAL:
                return 1;
            default:
                return 1;
        }
    }
}