package com.sptg.repeater.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;


/**
 * 响应 值对象
 * @author yb
 */
@ApiModel(value="api接口通用返回对象", description = "响应类")
public class Response {

	@ApiModelProperty(value = "返回码",dataType = "int", example="返回码（0才是成功，其他失败）")
	private int errno;
	@ApiModelProperty(value = "提示信息",dataType = "String", example="输出的提示信息")
	private String msg;

	private Object data;

	/** 响应处理是否成功 */
	public int getErrno() {
		return errno;
	}
	public void setErrno(int errno) {
		this.errno = errno;
	}

	/** 响应处理的消息 */
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}

	/** 响应处理的返回内容 */
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}

	public Response(int errno, String msg) {
		this.errno = errno;
		this.msg = msg;
	}

	public Response(Integer errno, String msg, Object data) {
		this.errno = errno;
		this.msg = msg;
		this.data = data;
	}

	public Response() {
	}

	public Response(int errno) {
		ErrorCodeEn errorCodeEn = ErrorCodeEn.fromCodeNo(errno);
		this.errno = errorCodeEn.getCode();
		this.msg = errorCodeEn.getDescription();
		this.data = null;
	}

	public Response(int errno, Object data) {
		ErrorCodeEn errorCodeEn = ErrorCodeEn.fromCodeNo(errno);
		this.errno = errorCodeEn.getCode();
		this.msg = errorCodeEn.getDescription();
		this.data = data;
	}

	public Response(Object data) {
		this.errno = 0;
		this.msg = "ok";
		this.data = data;
	}
}
