Class ResUtils

java.lang.Object
io.github.seenings.common.util.ResUtils

public class ResUtils extends Object
结果返回工具类
Since:
2022-02-19
Author:
chixuehui
See Also:
  • Method Details

    • createPage

      public static <T> ResultPage<T> createPage(List<T> pageList, Integer total)
      根据当前页内容创建分页结果对象
      Type Parameters:
      T - 列表元素类型
      Parameters:
      pageList - 当前页内容
      total - 总数
      Returns:
      分页结果对象
    • createR

      public static <T> R<T> createR(StatusCode statusCode, T data, String msg)
      生成R
      Type Parameters:
      T - 数据类型
      Parameters:
      statusCode - 状态码
      data - 数据
      msg - 消息
      Returns:
      r
    • ok

      public static <T> R<T> ok(T data, String msg)
      生成成功的R
      Type Parameters:
      T - 数据类型
      Parameters:
      data - 数据
      msg - 消息
      Returns:
      r
    • error

      public static <T> R<T> error(T data, String msg)
      生成失败的R
      Type Parameters:
      T - 数据类型
      Parameters:
      data - 数据
      msg - 消息
      Returns:
      r
    • error

      public static <T> R<T> error(String msg)
      生成失败的R
      Type Parameters:
      T - 数据类型
      Parameters:
      msg - 消息
      Returns:
      r
    • ok

      public static <T> R<T> ok(T data)
      生成成功的R
      Type Parameters:
      T - 数据类型
      Parameters:
      data - 数据
      Returns:
      r
    • successData

      public static <T> T successData(R<T> r) throws SeenException
      成功的数据
      Type Parameters:
      T - 对象类型
      Parameters:
      r - 结果对象
      Returns:
      数据
      Throws:
      SeenException - 不成功时的异常