package com.guo.learningprogresstracker.domain.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor public class CommonResult { private Integer code; private String message; private T data; public CommonResult(Integer code, String message){ this(code,message, null); } public static CommonResult success(){ return new CommonResult(200,"请求成功",null); } public static CommonResult success(String message){ return new CommonResult(200,message,null); } public static CommonResult success(String message,Object data){ return new CommonResult(200,message,data); } public static CommonResult success(Object data){ return new CommonResult(200,"请求成功",data); } public static CommonResult error(String message){ return new CommonResult<>(400,message,null); } public static CommonResult notFind(){ return new CommonResult<>(404,"请求的资源不存在",null); } public static CommonResult notFind(String message){ return new CommonResult<>(404,message,null); } public static CommonResult serverError(String message){ return new CommonResult<>(500,message,null); } }