返回结果对象ApiResult
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
-
- 说明: 接口返回数据对象
*/
@SuppressWarnings("serial")
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ApiResult implements Serializable {
/**
-
- 状态码
*/
private int code;
/**
-
- 状态说明
/
private String message;
/*
-
- 返回数据
*/
private Object data;
/**
-
- 返回集合数据数量
*/
private Long count;
/**
-
- 返回成功,有数据
- @param message 操作说明
- @param data 对象
- @return JsonResult
*/
public ApiResult success(String message, Object data) {
this.setCode(200);
this.setMessage(message);
this.setData(data);
return this;
}
/**
-
- 返回失败,有数据
- @param message 消息
- @param data 对象
- @return JsonResult
*/
public ApiResult error(int code, String message, Object data) {
this.setCode(code);
this.setMessage(message);
this.setData(data);
return this;
}
}
修改于 2022-02-21 08:42:09