12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- package com.gyee.impala.common.result;
- import com.alibaba.fastjson.JSONObject;
- import lombok.Data;
- import java.io.Serializable;
- import java.util.HashMap;
- @Data
- public class JsonResult extends HashMap<String, Object> implements Serializable {
- private Integer code;
- private String message;
- private Object data;
- private ResultCode resultCode;
- public static JSONObject error(){
- JSONObject json = new JSONObject();
- json.put("code", ResultCode.SUCCESS.getCode());
- json.put("msg", ResultCode.SUCCESS.getMessage());
- return json;
- }
- public static JSONObject error(ResultCode resultCode){
- JSONObject json = new JSONObject();
- json.put("code", resultCode.getCode());
- json.put("msg", resultCode.getMessage());
- return json;
- }
- public static JSONObject error(int code, String message){
- JSONObject json = new JSONObject();
- json.put("code", code);
- json.put("msg", message);
- return json;
- }
- public static JSONObject success(){
- JSONObject json = new JSONObject();
- json.put("code", ResultCode.SUCCESS.getCode());
- json.put("msg", ResultCode.SUCCESS.getMessage());
- return json;
- }
- public static JSONObject seccess(int code, String message){
- JSONObject json = new JSONObject();
- json.put("code", code);
- json.put("msg", message);
- return json;
- }
- public static JSONObject success(ResultCode resultCode){
- JSONObject json = new JSONObject();
- json.put("code", resultCode.getCode());
- json.put("msg", resultCode.getMessage());
- return json;
- }
- public static JSONObject successData(ResultCode code, Object data){
- JSONObject json = new JSONObject();
- json.put("code", code.getCode());
- json.put("msg", code.getMessage());
- json.put("data", data != null ? data : null);
- return json;
- }
- }
|