import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResponseMessage {
private int code;
private String msg;
private String description;
private Object data;
public ResponseMessage(int code, String msg) {
this.code = code;
this.msg = msg;
}
public static ResponseMessage successMessage(String message) {
return new ResponseMessage(200, "success", message, null);
}
public static ResponseMessage successMessage(String description, Object data) {
return new ResponseMessage(200, "success", description, data);
}
public static ResponseMessage successMessage(Object data) {
return new ResponseMessage(200, "success", null, data);
}
public static ResponseMessage failedMessage(String message) {
return new ResponseMessage(1, "failed", message, null);
}
public static ResponseMessage failedMessage(String message, Object data) {
return new ResponseMessage(1, "failed", message, data);
}
public static ResponseMessage permissionMessage(Object data) {
return new ResponseMessage(2, "permission denied", null, data);
}
public static ResponseMessage needLoginMessage() {
return new ResponseMessage(10, "need login");
}
public static ResponseMessage illegalMessage(String message) {
return new ResponseMessage(3, "illegal", message, null);
}
}