com.stalary.easydoc.data.JsonResult Maven / Gradle / Ivy
/**
* @(#)JSONResult.java, 2018-09-26.
*
* Copyright 2018 Stalary.
*/
package com.stalary.easydoc.data;
import com.alibaba.fastjson.JSONObject;
/**
* JsonResult
*
* @author lirongqian
* @since 2018/09/26
*/
public class JsonResult {
public static JSONObject ok() {
return ok(null);
}
public static JSONObject ok(T data) {
return new JSONObject()
.fluentPut("success", true)
.fluentPut("code", 0)
.fluentPut("data", data);
}
public static JSONObject failed() {
return failed(null);
}
public static JSONObject failed(String msg) {
return new JSONObject()
.fluentPut("success", false)
.fluentPut("code", -1)
.fluentPut("msg", msg);
}
}