Files
Nexus-api/src/main/java/com/dota/nexus/entity/R.java

42 lines
795 B
Java
Raw Normal View History

2025-10-10 11:40:34 +08:00
package com.dota.nexus.entity;
import lombok.Data;
@Data
public class R {
private Integer code;
private String msg;
private Object data;
2025-10-11 16:18:18 +08:00
public R(Integer code, String msg){
this.code = code;
this.msg = msg;
}
public R (Integer code, String msg, Object data) {
this.code = code;
this.msg = msg;
this.data = data;
}
2025-10-10 11:40:34 +08:00
public static R ok() {
return ok(null);
}
public static R ok(Object data) {
2025-10-11 16:18:18 +08:00
return new R(200, "ok", data);
2025-10-10 11:40:34 +08:00
}
2025-10-11 16:18:18 +08:00
public static R error(){
return new R(500, "服务端发生未知错误");
}
public static R unauthorized() {
return new R(401, "未授权,客户端没有提供认证信息");
}
public static R forbidden(){
return new R(403, "没有权限");
}
2025-10-10 11:40:34 +08:00
}