package com.example.jz.enums; public enum BusinessHttpStatus { // 未登录 UNAUTHORIZED(401, "未授权"); private final int value; private final String msg; BusinessHttpStatus(int value, String msg) { this.value = value; this.msg = msg; } /** * Return the integer value of this status code. */ public int value() { return this.value; } /** * Return the msg of this status code. */ public String getMsg() { return msg; } /** * Return a string representation of this status code. */ @Override public String toString() { return this.value + " " + name(); } public static BusinessHttpStatus valueOf(int statusCode) { BusinessHttpStatus status = resolve(statusCode); if (status == null) { throw new IllegalArgumentException("没有找到该Http状态码包含状态 [" + statusCode + "]"); } return status; } public static BusinessHttpStatus resolve(int statusCode) { for (BusinessHttpStatus status : values()) { if (status.value == statusCode) { return status; } } return null; } }