package com.fs.task.enums;

import lombok.Getter;

@Getter
public enum TaskFinishStatusEnum {

    UNFINISHED(0, "未完结"),
    FINISHED(1, "已完结");

    private final Integer code;
    private final String desc;

    TaskFinishStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static TaskFinishStatusEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (TaskFinishStatusEnum e : values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        throw new IllegalArgumentException("Unknown TaskFinishStatus code: " + code);
    }

    /**
     * 是否已完结（业务判断用）
     */
    public boolean isFinished() {
        return this == FINISHED;
    }
}
