package com.hz.pm.api.sys.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 *
 * 公告类型枚举
 * @author ZPF
 * @since 2023/02/24 16:14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum NoticeTypeEnum {
    /**
     * 公告类型枚举
     */
    ANNOUNCEMENT(1, "公告"),
    HELP_DOCUMENTS(2, "帮助文档"),
    POLICY_DOCUMENTS(3, "政策文件");

    private Integer code;
    private String desc;

    public static String getDescByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (NoticeTypeEnum t : NoticeTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getNameByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (NoticeTypeEnum t : NoticeTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.name();
            }
        }
        return StringUtils.EMPTY;
    }
}
