package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.valid.ValidEunm;

import java.util.Arrays;

/**
 * 消息发送范围枚举
 *
 * @Author: zhoupan
 * @Date: 2021/09/02/17:59
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum MessageSendRangeEnum implements ValidEunm, BaseEnum<Integer> {

    ALL(1, "全校"),
    DEPARTMENTS(2, "院系"),
    PERSON(3, "个人"),
    ;

    private Integer code;
    private String name;

    MessageSendRangeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static MessageSendRangeEnum getByCode(Integer code) {
        return Arrays.stream(MessageSendRangeEnum.values()).filter(a -> a.code.equals(code)).findFirst().orElse(null);
    }

    @Override
    public String codes() {
        return this.code.toString();
    }

    @Override
    public Integer getDictKey() {
        return code;
    }
}
