ResultVoUtil.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package thyyxxk.webserver.utils;
  2. import thyyxxk.webserver.config.exception.ExceptionEnum;
  3. import thyyxxk.webserver.entity.ResultVo;
  4. /**
  5. * @author dj
  6. */
  7. public class ResultVoUtil {
  8. public static <T> ResultVo<T> success() {
  9. return new ResultVo<>();
  10. }
  11. public static <T> ResultVo<T> success(T data) {
  12. return new ResultVo<>(data);
  13. }
  14. public static <T> ResultVo<T> success(ExceptionEnum exceptionEnum, String message) {
  15. return new ResultVo<>(exceptionEnum, message);
  16. }
  17. public static <T> ResultVo<T> success(ExceptionEnum exceptionEnum) {
  18. return new ResultVo<>(exceptionEnum);
  19. }
  20. public static <T> ResultVo<T> fail(ExceptionEnum exceptionEnum) {
  21. return new ResultVo<>(exceptionEnum);
  22. }
  23. public static <T> ResultVo<T> fail(ExceptionEnum exceptionEnum, String message) {
  24. return new ResultVo<>(exceptionEnum, message);
  25. }
  26. public static <T> ResultVo<T> fail(ExceptionEnum exceptionEnum, T data) {
  27. return new ResultVo<>(exceptionEnum, data);
  28. }
  29. public static <T> ResultVo<T> fail(ExceptionEnum exceptionEnum, String message, T data) {
  30. return new ResultVo<>(exceptionEnum, message, data);
  31. }
  32. }