package com.yingpaipay.business.enumeration;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.context.i18n.LocaleContextHolder;

import java.util.Locale;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum DocumentStatusEnum {

    UN_UPLOAD(0, "待上传", "Pending Upload"),
    UN_AUDIT(1, "待审核", "Pending Audit"),
    AUDIT_REJECT(2, "审核驳回", "Audit Reject"),
    UN_ARCHIEVED(3, "待归档", "Pending Archieved"),
    ARCHIEVED(4, "已归档", "Archieved"),
    UN_QC(5, "待质控", "Pending QC"),
    QC_PASS(6, "质控通过", "QC Pass"),
    QC_REJECT(7, "质控驳回", "QC Reject"),
    ;

    private final Integer value;
    private final String zhLabel;
    private final String enLabel;

    public static String getLabel(Integer value) {
        if (value == null) {
            return "";
        }
        DocumentStatusEnum status = null;
        for (DocumentStatusEnum enumeration : values()) {
            if (enumeration.getValue().equals(value)) {
                status = enumeration;
            }
        }
        if (status == null) {
            return "";
        }
        Locale locale = LocaleContextHolder.getLocale();
        if (locale.getLanguage().equals("zh")) {
            return status.getZhLabel();
        }
        return status.getEnLabel();
    }

}
