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 使用

  • 相关阅读:
    c#中的命名空间、类
    C#编写“hello,world”
    django1.9中manage.py的操作命令
    JS原生Ajax操作(XMLHttpRequest)
    Jquery百宝箱
    jQuery与Ajax入门
    JSON
    JSTL与EL表达式
    知识点整理
    Servlet与JSP进阶
  • 原文地址:https://www.cnblogs.com/zq1003/p/14149695.html
Copyright © 2011-2022 走看看