ResultInfo.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.gyee.runeconomy.dto;
  2. import lombok.Data;
  3. /**
  4. * @ClassName ResultInfo
  5. * @Description 返回结果类统一封装
  6. * @Author 谢生杰
  7. * @Date 2020/9/25 18:53
  8. * @Version 1.0
  9. **/
  10. @Data
  11. public class ResultInfo {
  12. // 状态码
  13. private Integer code;
  14. // 消息
  15. private String message;
  16. // 数据对象
  17. private Object result;
  18. private Integer total;
  19. /**
  20. * 无参构造器
  21. */
  22. public ResultInfo() {
  23. super();
  24. }
  25. public ResultInfo(Status status) {
  26. super();
  27. this.code = status.code;
  28. this.message = status.message;
  29. }
  30. public ResultInfo result(Object result) {
  31. this.result = result;
  32. return this;
  33. }
  34. public ResultInfo message(String message) {
  35. this.message = message;
  36. return this;
  37. }
  38. public ResultInfo total(Integer total) {
  39. this.total = total;
  40. return this;
  41. }
  42. /**
  43. * 只返回状态,状态码,消息
  44. *
  45. * @param code
  46. * @param message
  47. */
  48. public ResultInfo(Integer code, String message) {
  49. super();
  50. this.code = code;
  51. this.message = message;
  52. }
  53. /**
  54. * 只返回状态,状态码,数据对象
  55. *
  56. * @param code
  57. * @param result
  58. */
  59. public ResultInfo(Integer code, Object result) {
  60. super();
  61. this.code = code;
  62. this.result = result;
  63. }
  64. /**
  65. * 返回全部信息即状态,状态码,消息,数据对象
  66. *
  67. * @param code
  68. * @param message
  69. * @param result
  70. */
  71. public ResultInfo(Integer code, String message, Object result) {
  72. super();
  73. this.code = code;
  74. this.message = message;
  75. this.result = result;
  76. }
  77. }