package org.xyzh.common.vo;

import org.xyzh.common.dto.usercenter.TbAchievement;

import java.util.Date;

/**
 * @description 成就视图对象，包含成就信息、获得状态和进度信息
 * 继承TbAchievement，并包含TbUserAchievement和TbUserAchievementProgress的字段
 * @filename AchievementVO.java
 * @author yslg
 * @copyright xyzh
 * @since 2025-10-24
 */
public class AchievementVO extends TbAchievement {
    
    private static final long serialVersionUID = 1L;
    
    // ==================== TbUserAchievement表的字段 ====================
    
    /**
     * @description 用户成就记录ID（tb_user_achievement.ID）
     */
    private String userAchievementID;
    
    /**
     * @description 用户ID（tb_user_achievement.userID）
     */
    private String userID;
    
    /**
     * @description 获得时间（tb_user_achievement.obtainTime）
     */
    private Date obtainTime;
    
    // ==================== TbUserAchievementProgress表的字段 ====================
    
    /**
     * @description 进度记录ID（tb_user_achievement_progress.ID）
     */
    private String progressID;
    
    /**
     * @description 当前进度值（tb_user_achievement_progress.currentValue）
     */
    private Integer currentValue;
    
    /**
     * @description 目标进度值（tb_user_achievement_progress.targetValue）
     */
    private Integer targetValue;
    
    /**
     * @description 进度百分比 0-100（tb_user_achievement_progress.progressPercentage）
     */
    private Integer progressPercentage;
    
    /**
     * @description 是否已完成（tb_user_achievement_progress.completed）
     */
    private Boolean completed;
    
    /**
     * @description 最后更新时间（tb_user_achievement_progress.lastUpdateTime）
     */
    private Date lastUpdateTime;
    
    // ==================== 扩展字段（计算得出）====================
    
    /**
     * @description 是否已获得该成就（根据obtainTime判断）
     */
    private Boolean obtained;

    public AchievementVO() {
        super();
    }

    public String getUserAchievementID() {
        return userAchievementID;
    }

    public void setUserAchievementID(String userAchievementID) {
        this.userAchievementID = userAchievementID;
    }

    public String getUserID() {
        return userID;
    }

    public void setUserID(String userID) {
        this.userID = userID;
    }

    public Date getObtainTime() {
        return obtainTime;
    }

    public void setObtainTime(Date obtainTime) {
        this.obtainTime = obtainTime;
        // 自动设置obtained标志
        this.obtained = (obtainTime != null);
    }

    public String getProgressID() {
        return progressID;
    }

    public void setProgressID(String progressID) {
        this.progressID = progressID;
    }

    public Integer getCurrentValue() {
        return currentValue;
    }

    public void setCurrentValue(Integer currentValue) {
        this.currentValue = currentValue;
    }

    public Integer getTargetValue() {
        return targetValue;
    }

    public void setTargetValue(Integer targetValue) {
        this.targetValue = targetValue;
    }

    public Integer getProgressPercentage() {
        return progressPercentage;
    }

    public void setProgressPercentage(Integer progressPercentage) {
        this.progressPercentage = progressPercentage;
    }

    public Boolean getCompleted() {
        return completed;
    }

    public void setCompleted(Boolean completed) {
        this.completed = completed;
    }

    public Date getLastUpdateTime() {
        return lastUpdateTime;
    }

    public void setLastUpdateTime(Date lastUpdateTime) {
        this.lastUpdateTime = lastUpdateTime;
    }

    public Boolean getObtained() {
        return obtained;
    }

    public void setObtained(Boolean obtained) {
        this.obtained = obtained;
    }

    @Override
    public String toString() {
        return "AchievementVO{" +
                "achievementID='" + getAchievementID() + '\'' +
                ", name='" + getName() + '\'' +
                ", type=" + getType() +
                ", level=" + getLevel() +
                ", userAchievementID='" + userAchievementID + '\'' +
                ", userID='" + userID + '\'' +
                ", obtained=" + obtained +
                ", obtainTime=" + obtainTime +
                ", progressID='" + progressID + '\'' +
                ", currentValue=" + currentValue +
                ", targetValue=" + targetValue +
                ", progressPercentage=" + progressPercentage +
                ", completed=" + completed +
                ", lastUpdateTime=" + lastUpdateTime +
                '}';
    }
}

