package com.haha.common.enums;

public enum ContractStatus {

    PENDING("PENDING", "待签约"),
    ACTIVE("ACTIVE", "已生效"),
    EXPIRING("EXPIRING", "到期待续约"),
    TERMINATED("TERMINATED", "已解约终止");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ContractStatus fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (ContractStatus contractStatus : values()) {
            if (contractStatus.code.equals(code)) {
                return contractStatus;
            }
        }
        return null;
    }

    public static String getDescription(String code) {
        ContractStatus contractStatus = fromCode(code);
        return contractStatus != null ? contractStatus.description : "未知";
    }
}
