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

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * 消息模块按照业务分类枚举
 *
 * @author wangli
 * @date 2023/3/29 11:51
 */
@Getter
public enum ModuleBizTypeEnum {
  CONSTRUCTION(1, "施工"),
  TRADE(2, "交易"),
  ;

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

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

  public Integer getCode() {
    return code;
  }

  public String getMessage() {
    return message;
  }

  public static ModuleBizTypeEnum getByMessage(String message) {
    return Arrays.stream(values()).filter(it -> it.message.equals(message)).findFirst()
        .orElse(null);
  }

  public static ModuleBizTypeEnum valueOf(Integer code) {
    return Arrays.stream(values()).filter(it -> it.code.equals(code)).findFirst()
        .orElse(null);
  }
}
