RespDTO.java 1016 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.diagbot.dto;
  2. import java.io.Serializable;
  3. /**
  4. * @Description: 通用返回格式
  5. * @author: gaodm
  6. * @time: 2018/8/1 14:55
  7. */
  8. public class RespDTO<T> implements Serializable {
  9. public String code = "0";
  10. public String msg = "";
  11. public T data;
  12. public static RespDTO onSuc(Object data) {
  13. RespDTO resp = new RespDTO();
  14. resp.data = data;
  15. return resp;
  16. }
  17. public static RespDTO onSucBoth(String code,String msg,Object data) {
  18. RespDTO resp = new RespDTO();
  19. resp.code = code;
  20. resp.msg = msg;
  21. resp.data = data;
  22. return resp;
  23. }
  24. public static RespDTO onError(String errMsg) {
  25. RespDTO resp = new RespDTO();
  26. resp.code = "-1";
  27. resp.msg = errMsg;
  28. return resp;
  29. }
  30. @Override
  31. public String toString() {
  32. return "RespDTO{" +
  33. "code='" + code + '\'' +
  34. ", msg='" + msg + '\'' +
  35. ", data=" + data +
  36. '}';
  37. }
  38. }