All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.easyopen.ApiResult Maven / Gradle / Ivy

Go to download

easyopen mini版,保留基本签名校验,文档功能。https://gitee.com/durcframework/easyopen

There is a newer version: 1.0.4
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy