Result实体类
@Data public class Result { @ApiModelProperty(value = "是否成功") private Boolean success; @ApiModelProperty(value = "返回码") private Integer code; @ApiModelProperty(value = "返回消息") private String message; @ApiModelProperty(value = "返回数据") private Object data; private Result(){}; public static Result success() { Result result = new Result(); result.setSuccess(true); result.setCode(ResultCode.success); result.setMessage(" *** 作成功"); return result; } public static Result error() { Result result = new Result(); result.setCode(ResultCode.ERROR); result.setMessage(" *** 作失败"); result.setSuccess(false); return result; } public Result success(Boolean success) { this.setSuccess(true); return this; } public Result message(String message) { this.setMessage(message); return this; } public Result code(Integer code) { this.setCode(code); return this; } public Result data(Object data) { this.setData(data); return this; } }
返回码接口
public interface ResultCode { public static Integer success = 20000; public static Integer ERROR = 20001; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)