package com.fs.qw.enums;

import lombok.Getter;

import java.util.stream.Stream;

@Getter
public enum MsgType {
    TEXT(1, "text"),
    IMAGE(2, "image"),
    EMOTION_DYNAMIC(3, "emotionDynamic"),
    VOICE(4, "voice"),
    MINI_PROGRAM(5, "miniprogram"),
    ;

    private final Integer code;
    private final String value;

    MsgType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public static MsgType getMsgType(Integer code) {
        return Stream.of(values()).filter(t -> t.getCode().equals(code)).findFirst().orElse(null);
    }
}
