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 NoticePermissionsEnum {
    /**
     * 公告权限枚举
     */
    SUPER(0, "所有人可看"),
    REGION(1, "区域可看"),
    ORG(2, "单位可看");

    private Integer code;
    private String desc;

    public static String getDescByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (NoticePermissionsEnum t : NoticePermissionsEnum.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 (NoticePermissionsEnum t : NoticePermissionsEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.name();
            }
        }
        return StringUtils.EMPTY;
    }
}
