public class Constants {
public static final Integer SUCCESS_CODE = 200;
public static final Integer FAILURE_CODE = 404;
public static final String SUCCESS_MESSAGE = "success";
public static final String FAIL_MESSAGE = "fail";
}
public class Result {
private String message;
private Integer code;
private Object data;
public Result() {
}
public Result(String message, Integer code, Object data) {
this.message = message;
this.code = code;
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public static Result success() {
return new Result(Constants.SUCCESS_MESSAGE, Constants.SUCCESS_CODE, null);
}
public static Result success(Object data) {
return new Result(Constants.SUCCESS_MESSAGE, Constants.SUCCESS_CODE, data);
}
public static Result fail() {
return new Result(Constants.FAIL_MESSAGE, Constants.FAILURE_CODE, null);
}
public static Result fail(String message) {
return new Result(message, Constants.FAILURE_CODE, null);
}
}
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。