1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public class R extends HashMap<String, Object> { private R(ErrorCode errorCode) { put("code", errorCode.getCode()); put("message", errorCode.getMessage()); }
public static R ok(Object data) { R r = new R(OK); r.put("data", data); return r; }
public static R error(ErrorCode errorCode) { return new R(errorCode); }
private R(String message) { put("code", HttpStatus.INTERNAL_SERVER_ERROR.value()); put("message", message); }
public static R error(String message) { return new R(message); } }
|