package com.ssm.core.bean;

import com.github.pagehelper.PageInfo;
import com.ssm.manage.entity.SmsException;
import com.ssm.manage.response.ResponseCode;

import java.util.List;

public class PageResponse<T> {
    private String code;
    private String message;
    private PageInfo<T> pageInfo;
    private List<T> data;

    public String getCode() {
        return code;
    }

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

    public String getMessage() {
        return message;
    }

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

    public PageInfo<T> getPageInfo() {
        return pageInfo;
    }

    public void setPageInfo(PageInfo<T> pageInfo) {
        this.pageInfo = pageInfo;
    }

    public List<T> getData() {
        return data;
    }

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

    public PageResponse() {
    }

    public PageResponse(String code, String msg, PageInfo<T> pageInfo) {
        this.code = code;
        this.message = msg;
        this.pageInfo = pageInfo;
    }

    public void setCodeAndMsg(ResponseCode code, String msg) {
        this.code = code.getCode();
        this.message = String.format(code.getMsg(),msg);
    }

    public void setCodeAndMsg(ResponseCode code){
        this.code = code.getCode();
        this.message = code.getMsg();
    }
    public void setCodeAndMsg(SmsException e){
        this.code = e.getCode();
        this.message = e.getMessage();
    }
}
