java返回报文怎么看_java后端返回统一报文类

package com.czqc.czc.buz.api.beans.vo;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

public class ResponseStatus implements Serializable {

@ApiModelProperty("报文状态: 0 失败,1 成功,-1 未登录,-2 无权限")

private Integer status = 1;

@ApiModelProperty("报文: 成功响应报文,失败响应错误信息")

private T msg = (T) "ok";

public static ResponseStatus ok() {

return new ResponseStatus();

}

public static ResponseStatus list(Integer totalPages, Object content) {

return new ResponseStatus(totalPages, content);

}

public static ResponseStatus object(Object content) {

return new ResponseStatus(content);

}

public static ResponseStatus exception(Integer status, String errMsg) {

return new ResponseStatus(status, errMsg);

}

public ResponseStatus(T content) {

this.msg = content;

}

public ResponseStatus(Integer totalPages, T content) {

ResponseMsgVO responseMsgVO = new ResponseMsgVO<>();

responseMsgVO.setTotalPages(totalPages);

responseMsgVO.setContent(content);

this.msg = (T) responseMsgVO;

}

public ResponseStatus(Integer status, String msg) {

this.status = status;

this.msg = (T) msg;

}

public ResponseStatus() {

}

public Integer getStatus() {

return status;

}

public void setStatus(Integer status) {

this.status = status;

}

public T getMsg() {

return msg;

}

public void setMsg(T msg) {

this.msg = msg;

}

@Override

public String toString() {

return "MsgStatus{" +

"status=" + status +

", msg=" + msg +

'}';

}

public static class ResponseMsgVO implements Serializable {

@ApiModelProperty("总页数")

private Integer totalPages = 0;

@ApiModelProperty("内容")

private T content = (T) "ok";

public ResponseMsgVO(Integer totalPages, T content) {

this.totalPages = totalPages;

this.content = content;

}

public ResponseMsgVO(T content) {

this.content = content;

}

public ResponseMsgVO() {

}

public Integer getTotalPages() {

return totalPages;

}

public void setTotalPages(Integer totalPages) {

this.totalPages = totalPages;

}

public T getContent() {

return content;

}

public void setContent(T content) {

this.content = content;

}

@Override

public String toString() {

return "ResponseMsg0VO{" +

"totalPages=" + totalPages +

", content=" + content +

'}';

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值