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

 

posted @ 2020-12-17 15:02  未确定  阅读(282)  评论(0编辑  收藏  举报