com.gitee.easyopen.ApiResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easyopen-mini Show documentation
Show all versions of easyopen-mini Show documentation
easyopen mini版,保留基本签名校验,文档功能。https://gitee.com/durcframework/easyopen
package com.gitee.easyopen;
import com.gitee.easyopen.message.ErrorMeta;
import com.gitee.easyopen.message.Errors;
/**
* 默认的结果封装类.
*
* @author tanghc
*/
public class ApiResult implements Result {
private static final long serialVersionUID = -669758664098208583L;
private String code = Errors.SUCCESS.getCode();
private String msg;
private Object data;
public ApiResult() {
super();
}
public ApiResult(Object data) {
super();
this.data = data;
}
public static ApiResult success(Object data) {
ApiResult result = new ApiResult();
result.setData(data);
return result;
}
public static ApiResult error(ErrorMeta errorMeta) {
ApiResult result = new ApiResult();
result.setCode(errorMeta.getCode());
result.setMsg(errorMeta.getMsg());
return result;
}
@Override
public void setCode(Object code) {
this.code = String.valueOf(code);
}
@Override
public void setMsg(String msg) {
this.msg = msg;
}
@Override
public void setData(Object data) {
this.data = data;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
public Object getData() {
return data;
}
}