package com.matrix.core.pojo; 
 | 
  
 | 
import com.matrix.core.constance.SystemErrorCode; 
 | 
import com.matrix.core.tools.InternationaUtil; 
 | 
import com.matrix.core.tools.MdcUtil; 
 | 
import com.matrix.core.tools.StringUtils; 
 | 
import com.matrix.system.hive.plugin.message.StringUtil; 
 | 
  
 | 
import java.io.Serializable; 
 | 
import java.util.HashMap; 
 | 
import java.util.List; 
 | 
import java.util.Map; 
 | 
  
 | 
/** 
 | 
 * @author 姜友瑶 
 | 
 * @description Ajax请求返回的结果对象 
 | 
 * @data 2016-06-26 
 | 
 */ 
 | 
public class    AjaxResult implements Serializable { 
 | 
  
 | 
    private static final long serialVersionUID = 1L; 
 | 
    /** 
 | 
     * 请求成功 
 | 
     */ 
 | 
    public static final String STATUS_SUCCESS = "200"; 
 | 
    /** 
 | 
     * 请求未正常完成 
 | 
     **/ 
 | 
    public static final String STATUS_FAIL = SystemErrorCode.SYSTEM_ERROR_MSG; 
 | 
  
 | 
  
 | 
    /** 
 | 
     * 用户登录状态失效 
 | 
     */ 
 | 
    public static final String STATUS_LOGIN_INVALID = "700014"; 
 | 
  
 | 
  
 | 
    private String status; 
 | 
    /** 
 | 
     * 请求后跳转的页面 
 | 
     */ 
 | 
    private String page; 
 | 
    /** 
 | 
     * info会被国际化工具先处理,找不到国际化资源则显示原始信息 
 | 
     **/ 
 | 
    private String info; 
 | 
    private Map<Object, Object> mapInfo = new HashMap<>(); 
 | 
    private List<?> rows; 
 | 
    /** 
 | 
     * 总记录数 
 | 
     */ 
 | 
    private Integer total; 
 | 
  
 | 
    private String requestId; 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    public static AjaxResult buildSuccessInstance(String info) { 
 | 
        return new AjaxResult(STATUS_SUCCESS, info); 
 | 
    } 
 | 
  
 | 
    public static AjaxResult buildSuccessInstance(List<?> rows, String info) { 
 | 
        AjaxResult result= new AjaxResult(STATUS_SUCCESS, rows ); 
 | 
        result.setInfo(info); 
 | 
        return  result; 
 | 
    } 
 | 
    public static AjaxResult buildSuccessInstance(List<?> rows, Integer total) { 
 | 
        return new AjaxResult(STATUS_SUCCESS, rows, total); 
 | 
    } 
 | 
  
 | 
    public static AjaxResult buildSuccessInstance(List<?> rows) { 
 | 
        return new AjaxResult(STATUS_SUCCESS, rows); 
 | 
    } 
 | 
  
 | 
    public static AjaxResult buildFailInstance(String info) { 
 | 
        return new AjaxResult(STATUS_FAIL, info); 
 | 
    } 
 | 
  
 | 
  
 | 
    public AjaxResult() { 
 | 
    } 
 | 
  
 | 
    public AjaxResult(String status, List<?> rows, Integer total) { 
 | 
        this.status = status; 
 | 
        this.rows = rows; 
 | 
        this.total = total; 
 | 
        this.requestId= MdcUtil.getMdc(); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 设置简单信息,这是一个便捷的方法 
 | 
     * 
 | 
     * @param status 
 | 
     * @param page 
 | 
     * @param info 
 | 
     */ 
 | 
    public AjaxResult(String status, List<?> rows) { 
 | 
        this.status = status; 
 | 
        this.rows = rows; 
 | 
        this.requestId= MdcUtil.getMdc(); 
 | 
    } 
 | 
  
 | 
    public AjaxResult(String status, String info, Object... param) { 
 | 
        this.status = status; 
 | 
        if(StringUtils.isNotBlank(info)) { 
 | 
            this.info = InternationaUtil.getMesssge(info, param); 
 | 
        } 
 | 
        this.requestId= MdcUtil.getMdc(); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    public Integer getTotal() { 
 | 
        return total; 
 | 
    } 
 | 
  
 | 
    public void setTotal(Integer total) { 
 | 
        this.total = total; 
 | 
    } 
 | 
  
 | 
    public List<?> getRows() { 
 | 
        return rows; 
 | 
    } 
 | 
  
 | 
    public void setRows(List<?> rows) { 
 | 
        this.rows = rows; 
 | 
    } 
 | 
  
 | 
    public String getStatus() { 
 | 
        return status; 
 | 
    } 
 | 
  
 | 
    public void setStatus(String status) { 
 | 
        this.status = status; 
 | 
    } 
 | 
  
 | 
    public String getPage() { 
 | 
        return page; 
 | 
    } 
 | 
  
 | 
    public void setPage(String page) { 
 | 
        this.page = page; 
 | 
    } 
 | 
  
 | 
    public String getInfo() { 
 | 
        return info; 
 | 
    } 
 | 
  
 | 
    public void setInfo(String info) { 
 | 
        this.info = info; 
 | 
    } 
 | 
  
 | 
    public Map<Object, Object> getMapInfo() { 
 | 
        return mapInfo; 
 | 
    } 
 | 
  
 | 
    public void setMapInfo(Map<Object, Object> mapInfo) { 
 | 
        this.mapInfo = mapInfo; 
 | 
    } 
 | 
  
 | 
    public String getRequestId() { 
 | 
        return requestId; 
 | 
    } 
 | 
  
 | 
    public void setRequestId(String requestId) { 
 | 
        this.requestId = requestId; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 在map对象中放置信息 
 | 
     * 
 | 
     * @param key 
 | 
     * @param value 返回类型 void 
 | 
     * @author:姜友瑶 
 | 
     * @date 2016年9月11日 
 | 
     */ 
 | 
    public void putInMap(Object key, Object value) { 
 | 
        mapInfo.put(key, value); 
 | 
    } 
 | 
} 
 |