package org.xyzh.common.core.enums;

/**
 * @description 成就事件类型枚举
 * @filename AchievementEventType.java
 * @author yslg
 * @copyright xyzh
 * @since 2025-10-24
 */
public enum AchievementEventType {
    
    /**
     * 学习相关事件
     */
    LEARNING_TIME_UPDATED("learning_time_updated", "学习时长更新"),
    COURSE_COMPLETED("course_completed", "课程完成"),
    COURSE_STARTED("course_started", "开始学习课程"),
    CHAPTER_COMPLETED("chapter_completed", "章节完成"),
    
    /**
     * 资源相关事件
     */
    RESOURCE_VIEWED("resource_viewed", "浏览资源"),
    RESOURCE_COLLECTED("resource_collected", "收藏资源"),
    RESOURCE_SHARED("resource_shared", "分享资源"),
    
    /**
     * 任务相关事件
     */
    TASK_COMPLETED("task_completed", "任务完成"),
    TASK_ITEM_COMPLETED("task_item_completed", "任务项完成"),
    
    /**
     * 互动相关事件
     */
    COMMENT_POSTED("comment_posted", "发表评论"),
    LIKE_GIVEN("like_given", "点赞"),
    
    /**
     * 登录相关事件
     */
    USER_LOGIN("user_login", "用户登录"),
    CONTINUOUS_LOGIN("continuous_login", "连续登录"),
    
    /**
     * 积分相关事件
     */
    POINTS_EARNED("points_earned", "获得积分"),
    
    /**
     * 测试相关事件
     */
    TEST_PASSED("test_passed", "测试通过"),
    TEST_PERFECT_SCORE("test_perfect_score", "测试满分");
    
    private final String code;
    private final String description;
    
    AchievementEventType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据code获取事件类型
     */
    public static AchievementEventType fromCode(String code) {
        for (AchievementEventType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}

