package com.gt.util;
import com.jfinal.kit.Kv;
public class ResultUtil {
/**
* 请求失败,自定义失败信息
*
* @param msg 自定义失败信息
* @return Kv
* @author shackle
* @date 2022/11/7 14:39
*/
public static Kv errorMsg(String msg) {
return Kv.create().set("code", 500).set("msg", msg);
}
/**
* 请求成功,返回数据
*
* @param data 返回的数据
* @return Kv
* @author shackle
* @date 2022/11/7 14:39
*/
public static Kv successMsg(Object data) {
return Kv.create().set("code", 200).set("msg", "请求成功").set("data", data);
}
/**
* 请求失败,系统错误
*
* @return Kv
* @author shackle
* @date 2022/11/7 14:39
*/
public static Kv errorMsg() {
return Kv.create().set("code", 500).set("msg", "系统错误,请联系管理员");
}
/**
* 请求成功
*
* @return Kv
* @author shackle
* @date 2022/11/7 14:40
*/
public static Kv successMsg() {
return Kv.create().set("code", 200).set("msg", "请求成功");
}
}
自定义统一格式返回前端格式
于 2022-11-16 16:20:11 首次发布