package cn.axzo.msg.center.domain.enums;

import cn.axzo.basics.common.exception.ServiceException;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

/**
 * 消息路由地址类型
 *
 * @author: wangli
 * @date: 2022/3/21 20:48
 */
@Getter
public enum MsgRouteTypeEnum {

  WEB(1, "web"),
  MINI_PROGRAM(2, "mini_program"),
  IOS(3, "ios"),
  ANDROID(4, "android"),
  WEBVIEW(5, "webview"),
  WECHAT_MINI_PROGRAM(6, "wechat mini-program");

  @EnumValue
  private final Integer code;
  private final String message;

  MsgRouteTypeEnum(Integer code, String message) {
    this.code = code;
    this.message = message;
  }

  public Integer getCode() {
    return this.code;
  }

  public String getMessage() {
    return this.message;
  }

  public static MsgRouteTypeEnum getRouteType(Integer code) {
    MsgRouteTypeEnum[] values = values();
    for (MsgRouteTypeEnum item : values) {
      if (item.getCode().equals(code)) {
        return item;
      }
    }
    throw new ServiceException("路由类型不匹配 code:" + code);
  }
}
