-- 新版提交
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user