Envelop.java 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.yihu.wlyy.controller.endpoint;
  2. import com.fasterxml.jackson.annotation.JsonInclude;
  3. import com.yihu.wlyy.controller.endpoint.status.EnvelopStatus;
  4. import java.io.Serializable;
  5. /**
  6. * Rest Model - 基类
  7. */
  8. @JsonInclude(JsonInclude.Include.ALWAYS)
  9. public class Envelop implements Serializable {
  10. protected String message;
  11. protected Integer status = EnvelopStatus.success.code;
  12. public Integer getStatus() {
  13. return status;
  14. }
  15. public void setStatus(Integer status) {
  16. this.status = status;
  17. }
  18. public String getMessage() {
  19. return message;
  20. }
  21. public void setMessage(String message) {
  22. this.message = message;
  23. }
  24. public static Envelop getSuccess(String message) {
  25. Envelop envelop = new Envelop();
  26. envelop.setMessage(message);
  27. envelop.setStatus(200);
  28. return envelop;
  29. }
  30. public static Envelop getError(String message, int errorCode) {
  31. Envelop envelop = new Envelop();
  32. envelop.setMessage(message);
  33. envelop.setStatus(errorCode);
  34. return envelop;
  35. }
  36. public static Envelop getError(String message) {
  37. Envelop envelop = new Envelop();
  38. envelop.setMessage(message);
  39. envelop.setStatus(-1);
  40. return envelop;
  41. }
  42. }