重写复现方法

This commit is contained in:
2025-08-28 18:09:20 +08:00
parent 0c26e0911e
commit 2948a25d9f
15 changed files with 887 additions and 8 deletions

View File

@@ -0,0 +1,52 @@
package com.mini.capi.model.auth;
import lombok.Data;
import java.io.Serializable;
@Data
public class Result implements Serializable {
// 状态码200表示成功其他表示错误
private int code;
// 响应信息
private String msg;
// 响应数据(可选)
private Object data;
// 私有构造方法,防止直接创建实例
private Result() {}
// 成功响应
public static Result success(String msg) {
Result result = new Result();
result.code = 200;
result.msg = msg;
return result;
}
// 带数据的成功响应
public static Result success(String msg, Object data) {
Result result = new Result();
result.code = 200;
result.msg = msg;
result.data = data;
return result;
}
// 错误响应
public static Result error(String msg) {
Result result = new Result();
result.code = 500; // 500表示服务器错误也可以根据实际情况使用其他错误码
result.msg = msg;
return result;
}
// 带自定义错误码的错误响应
public static Result error(int code, String msg) {
Result result = new Result();
result.code = code;
result.msg = msg;
return result;
}
}