package com.test.common.enums;

/**
 * @author liangdaliang
 * @Description：缺陷状态枚举
 * @date 2025-04-23 13:59
 */
public enum EnumDefectStatus {
    PENDING_CONFIRMATION("0", "待确认"),
    UNDER_REPAIR("1", "修复中"),
    COMPLETED("2", "已完成"),
    INVALID_DEFECT("3", "无效缺陷"),
    SUSPENDED("4", "挂起"),
    PENDING_VERIFICATION("5", "待验证");

    private final String code;
    private final String description;

    EnumDefectStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态码获取对应的枚举值
     */
    public static EnumDefectStatus fromCode(String code) {
        for (EnumDefectStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的状态码: " + code);
    }

    /**
     * 根据状态码获取中文描述（可选）
     */
    public static String getDescriptionByCode(String code) {
        return fromCode(code).getDescription();
    }
}
