AjaxResult.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package cn.ele6.catalyzer.ruoyi.enhance;
  2. import cn.ele6.catalyzer.ruoyi.custom.RuoYiResponse;
  3. import com.ruoyi.common.constant.HttpStatus;
  4. import org.springframework.beans.BeanUtils;
  5. import java.io.Serializable;
  6. /**
  7. * 改造。
  8. */
  9. public class AjaxResult extends com.ruoyi.common.core.domain.AjaxResult implements Serializable, RuoYiResponse {
  10. /**
  11. * 返回成功消息
  12. * copy.
  13. *
  14. * @return 成功消息
  15. */
  16. public static AjaxResult success() {
  17. return convert(com.ruoyi.common.core.domain.AjaxResult.success("操作成功"));
  18. }
  19. /**
  20. * 返回成功数据
  21. * copy.
  22. *
  23. * @return 成功消息
  24. */
  25. public static AjaxResult success(Object data) {
  26. return convert(com.ruoyi.common.core.domain.AjaxResult.success("操作成功", data));
  27. }
  28. /**
  29. * 返回成功消息
  30. * copy.
  31. *
  32. * @param msg 返回内容
  33. * @return 成功消息
  34. */
  35. public static AjaxResult success(String msg) {
  36. return convert(com.ruoyi.common.core.domain.AjaxResult.success(msg, null));
  37. }
  38. /**
  39. * 返回成功消息
  40. * copy.
  41. *
  42. * @param msg 返回内容
  43. * @param data 数据对象
  44. * @return 成功消息
  45. */
  46. public static AjaxResult success(String msg, Object data) {
  47. return convert(new com.ruoyi.common.core.domain.AjaxResult(HttpStatus.SUCCESS, msg, data));
  48. }
  49. /**
  50. * 返回警告消息
  51. * copy.
  52. *
  53. * @param msg 返回内容
  54. * @return 警告消息
  55. */
  56. public static AjaxResult warn(String msg) {
  57. return convert(com.ruoyi.common.core.domain.AjaxResult.warn(msg, null));
  58. }
  59. /**
  60. * 返回警告消息
  61. * copy.
  62. *
  63. * @param msg 返回内容
  64. * @param data 数据对象
  65. * @return 警告消息
  66. */
  67. public static AjaxResult warn(String msg, Object data) {
  68. return convert(new com.ruoyi.common.core.domain.AjaxResult(HttpStatus.WARN, msg, data));
  69. }
  70. /**
  71. * 返回错误消息
  72. * copy.
  73. *
  74. * @return 错误消息
  75. */
  76. public static AjaxResult error() {
  77. return convert(com.ruoyi.common.core.domain.AjaxResult.error("操作失败"));
  78. }
  79. /**
  80. * 返回错误消息
  81. * copy.
  82. *
  83. * @param msg 返回内容
  84. * @return 错误消息
  85. */
  86. public static AjaxResult error(String msg) {
  87. return convert(com.ruoyi.common.core.domain.AjaxResult.error(msg, null));
  88. }
  89. /**
  90. * 返回错误消息
  91. * copy.
  92. *
  93. * @param msg 返回内容
  94. * @param data 数据对象
  95. * @return 错误消息
  96. */
  97. public static AjaxResult error(String msg, Object data) {
  98. return convert(new com.ruoyi.common.core.domain.AjaxResult(HttpStatus.ERROR, msg, data));
  99. }
  100. /**
  101. * 返回错误消息
  102. * copy.
  103. *
  104. * @param code 状态码
  105. * @param msg 返回内容
  106. * @return 错误消息
  107. */
  108. public static AjaxResult error(int code, String msg) {
  109. return convert(new com.ruoyi.common.core.domain.AjaxResult(code, msg, null));
  110. }
  111. /**
  112. * copy obj and convert type.
  113. *
  114. * @param o
  115. * @return
  116. */
  117. public static AjaxResult convert(com.ruoyi.common.core.domain.AjaxResult o) {
  118. AjaxResult t = new AjaxResult();
  119. BeanUtils.copyProperties(o, t);
  120. return t;
  121. }
  122. }