• 封装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 使用

  • 相关阅读:
    2020年9月29日
    随机生成验证码
    动手动脑java语法基础
    Java语法之动手实验
    代码大全2 读书笔记
    java动手动动脑之字串联接
    二柱子问题
    生成随机四则运算1
    可变参数
    2020年9月30日
  • 原文地址:https://www.cnblogs.com/zq1003/p/14149695.html
Copyright © 2020-2023  润新知