自定义后端返回值
package com.example.teamapplication.common; import lombok.Data; /** * 功能: * 作者: * 日期: 2024/2/12 21:00 */ @Data public class Result { private int code; private String msg; private Long total; private Object data; public static Result fail(){ return result(400,"失败",0L,null); } public static Result suc(){ return result(200,"成功",0L,null); } public static Result success() { Result result = new Result(); result.setCode(200); result.setMsg("请求成功"); return result; } public static Result success(Object data) { Result result = success(); result.setData(data); return result; } public static Result suc(Object data){ return result(200,"成功",0L,data); } public static Result suc(Object data,Long total){ return result(200,"成功",total,data); } private static Result result(int code ,String msg,Long total,Object data){ Result res = new Result(); res.setData(data); res.setMsg(msg); res.setCode(code); res.setTotal(total); return res; } }View Code
再次进行测试,详情见上篇
标签:return,冲刺,static,Result,第二阶段,data,public,result From: https://www.cnblogs.com/azure011328/p/18247479