package com.bonus.common.biz.enums;

import lombok.Getter;

@Getter
public enum MessageTypeEnum {

    CHAT_MESSAGE(0, "点对点聊天"),
    ORDER_MESSAGE(1, "订单状态消息"),
    DEMAND_MESSAGE(2, "需求状态消息"),
    QUALITY_CONTROL_MESSAGE(3,"质检到期消息"),
    OTHER(99,"其他");

    private final Integer type;
    private final String name;

    MessageTypeEnum(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    /**
     * 根据code获取name
     * @param type
     * @return
     */
    public static String getNameByCode(int type) {
        MessageTypeEnum[] maStatusEnums = values();
        for (MessageTypeEnum maStatusEnum : maStatusEnums) {
            if (maStatusEnum.getType() == type) {
                return maStatusEnum.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String msg) {
        MessageTypeEnum[] maStatusEnums = values();
        for (MessageTypeEnum maStatusEnum : maStatusEnums) {
            if (maStatusEnum.getName() == msg) {
                return maStatusEnum.getType();
            }
        }
        return null;
    }


}
