package com.haha.common.enums;

public enum AttachmentType {

    CONTRACT("CONTRACT", "合同附件"),
    LEASE_AGREEMENT("LEASE_AGREEMENT", "场地租赁协议"),
    ELECTRICITY_AGREEMENT("ELECTRICITY_AGREEMENT", "电费补充协议"),
    DEPOSIT_RECEIPT("DEPOSIT_RECEIPT", "保证金收据"),
    TERMINATION_AGREEMENT("TERMINATION_AGREEMENT", "解约/补充变更协议");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

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