Browse Source

上传文件至 'HanGouT_BackEnd-master/src/main/java/com/example/hangoutspringboot/common'

master
曹天怡 2 years ago
parent
commit
5bca0faa56
1 changed files with 60 additions and 0 deletions
  1. +60
    -0
      HanGouT_BackEnd-master/src/main/java/com/example/hangoutspringboot/common/Result.java

+ 60
- 0
HanGouT_BackEnd-master/src/main/java/com/example/hangoutspringboot/common/Result.java View File

@ -0,0 +1,60 @@
package com.example.hangoutspringboot.common;
public class Result<T> {
private String code;
private String msg;
private T data;
// 表示泛型 任何数据类型都可以被result包含
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public Result() {
}
public Result(T data) {
this.data = data;
}
public static Result success() {
Result result = new Result<>();
result.setCode("0");
result.setMsg("成功");
return result;
}
public static <T> Result<T> success(T data) {
Result<T> result = new Result<>(data);
result.setCode("0");
result.setMsg("成功");
return result;
}
public static Result error(String code, String msg) {
Result result = new Result();
result.setCode(code);
result.setMsg(msg);
return result;
}
}

Loading…
Cancel
Save