package cn.superdesk.uniorder.common.rest.response;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.Map;

/**
 * @Description: 待调整
 * @Author: linjinyu
 * @CreateDate: 2021/10/27 下午3:00
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/27 下午3:00
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class R<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	// 请求code
	private String  code    = "200";
	// 请求状态
	private boolean success = true;
	// 错误消息
	private String  message;
	// 返回数据
	private T       data;

	@JsonProperty(access = JsonProperty.Access.READ_ONLY)
	private Map<String, Object> headData;

	/**
	 * currentPage
	 */
	private int currentPage;
	/**
	 * pageSize
	 */
	private int pageSize;
	/**
	 * totalRows
	 */
	private int count;

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public R(int currentPage, int pageSize, int count, T data) {
		super();
		this.data = data;
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.count = count;
	}

	public R(int currentPage, int pageSize, int count, T data, Map<String, Object> headData) {
		super();
		this.data = data;
		this.headData = headData;
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.count = count;
	}

	public R() {
		super();
	}

	public R(String code, String message, boolean success) {
		super();
		this.code = code;
		this.success = success;
		this.message = message;
	}

	public R(String code, String message, T data) {
		super();
		this.code = code;
		this.message = message;
		this.data = data;
	}

	public R(T data) {
		super();
		this.data = data;
	}

	public R(String code, String message, T data, boolean success) {
		super();
		this.code = code;
		this.message = message;
		this.data = data;
		this.success = success;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setCode(Integer code) {
		this.code = String.valueOf(code);
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public Map<String, Object> getHeadData() {
		return headData;
	}

	public void setHeadData(Map<String, Object> headData) {
		this.headData = headData;
	}

}
