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/06/8:57
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum MessTypeEnum implements ValidEunm, BaseEnum<Integer> {
    TEXT(0, "文字"),
    RICH_TEXT(1, "富文本"),
    ;

    private Integer code;
    private String name;

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

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

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

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

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