ResultVO 返回前端實體類


package com.aaa.controller.vm;

import lombok.Data;

import java.io.Serializable;

/**

  • Created by cws

  • @author Administrator
    */
    @Data
    public class ResultVO implements Serializable {
    private static final long serialVersionUID = 1L;

    public static final Integer CODE = 0;

    private Integer code;

    private String msg;

    private Object result;

    public ResultVO() {

    }

    public ResultVO(Integer code) {
    this.code = code;
    }

    public ResultVO(Integer code, String msg) {
    this.code = code;
    this.msg = msg;
    }

    public ResultVO(Integer code, Object result) {
    this.code = code;
    this.result = result;
    }

    public ResultVO(Integer code, String msg, Object result) {
    this.code = code;
    this.msg = msg;
    this.result = result;
    }

    public ResultVO(Object result) {
    this.result = result;
    }

    public static ResultVO error() {
    return error(500, "未知異常,請聯系管理員");
    }

    public static ResultVO error(String msg) {
    return error(500, msg);
    }

    public static ResultVO error(Integer code, String msg) {
    return new ResultVO(code, msg);
    }

    /**

    • 帶通用返回數據
    • @param msg
    • @param result
    • @return
      */
      public static ResultVO ok(String msg, Object result) {
      return new ResultVO(CODE, msg, result);
      }

    /**

    • 不帶數據
    • @param msg
    • @return
      */
      public static ResultVO ok(String msg) {
      return new ResultVO(CODE, msg);
      }

    /**

    • 帶數據
    • @param result
    • @return
      */
      public static ResultVO ok(Object result) {
      return new ResultVO(CODE, result);
      }

    /**

    • 只帶狀態碼
    • @return
      */
      public static ResultVO ok() {
      return new ResultVO(CODE);
      }
      }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM