All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.litongjava.db.TableResult Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package com.litongjava.db;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class TableResult implements java.io.Serializable {
  private static final long serialVersionUID = 3937468350139608391L;

  // 状态码 1 success 0 fail
  private int code = 1;

  // 状态说明
  private String msg;

  // 数据内容
  private T data;

  public TableResult(T data) {
    this.data = data;
  }

  public TableResult(int code) {
    this.code = code;
  }

  public TableResult(String msg) {
    this.msg = msg;
  }

  public TableResult(int code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  public static  TableResult fail() {
    return new TableResult(-1, "fail");
  }

  public static  TableResult fail(int code) {
    return new TableResult(code, "fail");
  }

  public static  TableResult fail(String message) {
    return new TableResult(-1, message);
  }

  public static  TableResult fail(T data) {
    return new TableResult(-1, "fail", data);
  }

  public static  TableResult fail(int code, String msg) {
    return new TableResult(code, msg);
  }

  public static  TableResult ok() {
    return new TableResult();
  }

  public static  TableResult ok(T kv) {
    return new TableResult(kv);
  }

  public boolean isOk() {
    return this.code == 1;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy