ContentStatus.java 2.7 KB
package com.aigeo.common.enums;

import lombok.Getter;

/**
 * 内容状态枚举
 * 对应数据库字段:
 * - ai_keywords.status
 * - ai_topics.status
 * - ai_articles.status
 * - ai_landing_page_projects.status
 * - ai_website_projects.status
 *
 * @author AIGEO Team
 * @since 1.0.0
 */
@Getter
public enum ContentStatus {
    
    /**
     * 待处理 - 内容已创建,等待处理
     */
    PENDING("pending", "待处理"),
    
    /**
     * 已计划 - 内容已安排进入生成计划
     */
    PLANNED("planned", "已计划"),
    
    /**
     * 已生成 - 内容生成完成
     */
    GENERATED("generated", "已生成"),
    
    /**
     * 已发布 - 内容已发布到目标平台
     */
    PUBLISHED("published", "已发布"),
    
    /**
     * 草稿 - 内容处于草稿状态
     */
    DRAFT("draft", "草稿"),
    
    /**
     * 已审核 - 内容已通过审核
     */
    APPROVED("approved", "已审核"),
    
    /**
     * 已归档 - 内容已归档
     */
    ARCHIVED("archived", "已归档"),
    
    /**
     * 已删除 - 内容已标记删除
     */
    DELETED("deleted", "已删除"),
    
    /**
     * 配置中 - 正在配置参数
     */
    CONFIGURING("configuring", "配置中"),
    
    /**
     * 生成中 - 正在生成内容
     */
    GENERATING("generating", "生成中"),
    
    /**
     * 已完成 - 所有流程完成
     */
    COMPLETED("completed", "已完成");

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

    ContentStatus(String code, String displayName) {
        this.code = code;
        this.displayName = displayName;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static ContentStatus fromCode(String code) {
        for (ContentStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的内容状态代码: " + code);
    }
    
    /**
     * 检查是否为最终状态
     */
    public boolean isFinalStatus() {
        return this == PUBLISHED || this == ARCHIVED || this == DELETED || this == COMPLETED;
    }
    
    /**
     * 检查是否可以编辑
     */
    public boolean isEditable() {
        return this == DRAFT || this == PENDING;
    }
    
    /**
     * 检查是否正在处理中
     */
    public boolean isProcessing() {
        return this == CONFIGURING || this == GENERATING;
    }
    
    /**
     * 检查是否可以发布
     */
    public boolean canPublish() {
        return this == APPROVED || this == GENERATED || this == COMPLETED;
    }
}