zoukankan      html  css  js  c++  java
  • 封装Result 结果集

     1 import java.io.Serializable;
     2 
     3 public class Result implements Serializable {
     4     private static final long serialVersionUID = 1L;
     5     Object data;
     6     int code;
     7     String message;
     8 
     9     public Result() {
    10         this.code = ResultCode.SUCCESS.code;
    11     }
    12 
    13     public void setResultCode(ResultCode item) {
    14         this.code = item.code;
    15         this.message = item.message;
    16     }
    17 
    18     public Object getData() {
    19         return this.data == null ? "" : this.data;
    20     }
    21 
    22     public void setData(Object data) {
    23         this.data = data;
    24     }
    25 
    26     public int getCode() {
    27         return this.code;
    28     }
    29 
    30     public String getMessage() {
    31         return this.message == null ? "" : this.message;
    32     }
    33 }

    setResultCode

    import java.io.Serializable;
    
    public class ResultCode implements Serializable {
        public int code;
        public String message;
        public static final ResultCode SUCCESS = new ResultCode(0, "");
        public static final ResultCode FAILED = new ResultCode(-1, "");
    
        public ResultCode() {
        }
    
        public ResultCode(int code, String message) {
            this.code = code;
            this.message = message;
        }
    }

     2 使用

  • 相关阅读:
    MVC 小demo
    单例模式
    简单工厂模式
    有关ajax中的URL问题
    SqlHelper++
    C# 操作XML
    C# 注册DLL(使用cmd)
    图片延迟加载库Layzr
    解决Ajax跨域问题:Origin xx is not allowed by Access-Control-Allow-Origin.
    HTML5 + SOCKET视频传输
  • 原文地址:https://www.cnblogs.com/zq1003/p/14149695.html
Copyright © 2011-2022 走看看