com.github.yiuman.citrus.support.http.ResponseEntity Maven / Gradle / Ivy
package com.github.yiuman.citrus.support.http;
/**
* @author yiuman
* @date 2020/3/30
*/
public class ResponseEntity {
private Integer code;
private T data;
private String message = "";
public ResponseEntity() {
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static ResponseEntity ok() {
return ResponseEntity.ok(null);
}
public static ResponseEntity ok(T data) {
ResponseEntity responseResult = new ResponseEntity<>();
responseResult.setCode(ResponseStatusCode.OK);
responseResult.setData(data);
return responseResult;
}
public static ResponseEntity badRequest(String message) {
return error(ResponseStatusCode.BAD_REQUEST, message);
}
public static ResponseEntity error(String message) {
return error(ResponseStatusCode.SERVER_ERROR, message);
}
public static ResponseEntity error(Integer code, String message) {
ResponseEntity responseResult = new ResponseEntity<>();
responseResult.setCode(code);
responseResult.setMessage(message);
return responseResult;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy