package com.cwy.wxapp.util;
import java.util.HashMap;
/**
* 返回结果对象工具类
*/
public class JsonResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
private JsonResult() {
}
/**
* 返回成功
*/
public static JsonResult ok() {
return ok("操作成功");
}
/**
* 返回成功
*/
public static JsonResult ok(String message) {
return ok(200, message);
}
/**
* 返回成功
*/
public static JsonResult ok(int code, String message) {
JsonResult jsonResult = new JsonResult();
jsonResult.put("code", code);
jsonResult.put("msg", message);
return jsonResult;
}
/**
* 返回失败
*/
public static JsonResult error() {
return error("操作失败");
}
/**
* 返回失败
*/
public static JsonResult error(String messag) {
return error(500, messag);
}
/**
* 返回失败
*/
JsonResult 返回结果对象工具类(适用于小程序开发)
最新推荐文章于 2024-04-28 14:16:20 发布