package com.ozs.da.entity;

import com.ozs.da.constant.StatusCode;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author 宋显哲
 * @version 1.0.0 创建于 2017/12/27
 **/
@ApiModel(description = "请求返回实体类", value = "返回值")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ReturnData<T> {
    @ApiModelProperty(dataType = "int", name = "code", value = "请求返回状态码")
    private String code = StatusCode.SUCCESS;
    @ApiModelProperty(dataType = "String", name = "msg", value = "请求返回描述信息")
    private String msg = "请求成功.";
    @ApiModelProperty(dataType = "T", name = "data", value = "返回数据")
    T data;
    private Integer page;
    private Integer pageSize;
    private Integer totalNumber;
    private Integer totalPageCount;

    public ReturnData() {
    }

    public ReturnData(T data) {
        this.data = data;
    }

    public ReturnData(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ReturnData(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public ReturnData<T> setData(T data) {
        this.data = data;
        return this;
    }

    public ReturnData<T> retStatus(String code) {
        this.setCode(code);
        this.setMsg(StatusCode.getMsg(code));
        return this;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getPageSize() {
        return pageSize;
    }

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

    public Integer getTotalNumber() {
        return totalNumber;
    }

    public void setTotalNumber(Integer totalNumber) {
        this.totalNumber = totalNumber;
    }

    public Integer getTotalPageCount() {
        return totalPageCount;
    }

    public void setTotalPageCount(Integer totalPageCount) {
        this.totalPageCount = totalPageCount;
    }
}
