package cn.van333.mt2ql.wxMessage.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Leo
 * @version 1.0
 * @create 2023/12/19 0019 下午 02:31
 * @description：
 */
public enum MsgTypeEnum implements IEnum {
    /**
     msgType	：
     1|文本 3|图片 34|语音
     42|名片 43|视频 47|动态表情
     48|地理位置 49|分享链接或附件 2001|红包
     2002|小程序 2003|群邀请 10000|系统消息    * */
    TEXT(1, "文本"),
    IMAGE(3, "图片"),
    VOICE(34, "语音"),
    ANIMATION(47, "动态表情"),
    //名片 42
    CARD(42, "名片"),


    VIDEO(43, "视频"),
    SHARE(49, "分享链接或附件"),
    LOCATION(48, "位置"),
    REDPACKET(2001, "红包"),
    MINIPROGRAM(2002, "小程序"),
    GROUP_INVITE(2003, "群邀请"),
    SYSTEM(10000, "系统消息"),
    ;
    private final int key;

    private final String name;

    MsgTypeEnum(int key, String name) {
        this.key = key;
        this.name = name;
    }

    public static String getName(Integer key) {
        for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
            if (msgTypeEnum.key == key) {
                return msgTypeEnum.name;
            }
        }
        return null;
    }

    public static Map<String, String> getKeyVlue() {
        Map<String, String> map = new HashMap<>();
        for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
            map.put(msgTypeEnum.key + "", msgTypeEnum.name);
        }
        return map;
    }

    public static List<Map<String, Object>> getSelectItems() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("key", msgTypeEnum.key);
            map.put("value", msgTypeEnum.name);
            list.add(map);
        }
        return list;
    }

    public static MsgTypeEnum get(int key) {
        for (MsgTypeEnum msgTypeEnum : MsgTypeEnum.values()) {
            if (msgTypeEnum.key == key) {
                return msgTypeEnum;
            }
        }
        return null;
    }

    public Integer getKey() {
        return key;
    }

    public String getName() {
        return name;
    }

}
