-- 新版提交

This commit is contained in:
yc13649764453
2023-09-09 13:51:35 +08:00
parent 763e24b4e0
commit 0b193caa03
92 changed files with 3451 additions and 1120 deletions

View File

@@ -8,6 +8,8 @@
package com.peanut.common.utils;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.http.HttpStatus;
import java.util.HashMap;
@@ -18,6 +20,8 @@ import java.util.Map;
*
* @author Mark sunlightcs@gmail.com
*/
@Data
//@Accessors(chain = true)
public class R extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
@@ -25,14 +29,44 @@ public class R extends HashMap<String, Object> {
put("code", 0);
put("msg", "success");
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
// return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
}
/**
* int SC_NOT_IMPLEMENTED = 501;
* int SC_BAD_GATEWAY = 502;
* int SC_SERVICE_UNAVAILABLE = 503;
* int SC_GATEWAY_TIMEOUT = 504;
* @param
* @param msg
* @return
*/
public static R error1(String msg) {
return error(HttpStatus.SC_NOT_IMPLEMENTED, msg);
}
public static R error2() {
return error(HttpStatus.SC_BAD_GATEWAY,"");
}
public static R error3(String msg) {
return error(HttpStatus.SC_SERVICE_UNAVAILABLE, msg);
}
public static R error4(String msg) {
return error(HttpStatus.SC_GATEWAY_TIMEOUT, msg);
}
public static R error(int code, String msg) {
R r = new R();