ApiController.java 778 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.jg.common;
  2. /**
  3. * <p>
  4. * REST API 通用控制器
  5. * </p>
  6. *
  7. * @author lxp
  8. * @version V1.0
  9. * @since 2022/7/20 0:04
  10. */
  11. public class ApiController {
  12. /**
  13. * 请求成功
  14. *
  15. * @param data 数据内容
  16. * @param <T> 对象泛型
  17. * @return ignore
  18. */
  19. protected <T> Result<T> ok(T data) {
  20. return Result.ok(data);
  21. }
  22. /**
  23. * 请求失败
  24. *
  25. * @param msg 提示内容
  26. * @return ignore
  27. */
  28. protected <T> Result<T> failed(String msg) {
  29. return Result.failed(msg);
  30. }
  31. /**
  32. * 请求失败
  33. *
  34. * @param errorCode 请求错误码
  35. * @return ignore
  36. */
  37. protected <T> Result<T> failed(ErrorCode errorCode) {
  38. return Result.failed(errorCode);
  39. }
  40. }