本文共 938 字,大约阅读时间需要 3 分钟。
package com.example.youruan.day01.entity;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;@Data@AllArgsConstructor@NoArgsConstructorpublic class ResultEntity{ private static final String SUCCESS = "success"; private static final String ERROR = "error"; private String status;//请求成功还是失败 private String message;//失败得原因 private T data;//返回得数据 public static ResultEntity success() { return new ResultEntity<>(SUCCESS, null, null); } public static ResultEntity success(T t) { return new ResultEntity<>(SUCCESS, null, t); } public static ResultEntity error(String message) { return new ResultEntity<>(ERROR, message, null); } public static ResultEntity responseClient(boolean flag) { if (flag) { return ResultEntity.success(); } else { return ResultEntity.error("失败"); } }}
转载地址:http://shrwi.baihongyu.com/