package cn.hmsoft.application.web;

import java.util.List;
import java.util.Map;

import cn.hmsoft.exception.AppException;
import cn.hmsoft.frame.data.model.FrameThread;
import cn.hmsoft.jdbc.entity.Pager;

/*******************************
 * ajax返回实体
 * 
 * @author zxq
 * @create 2019-05-27 11:48:41
 * @version 2.0.0
 * @email: revisit@126.com
 * @Company: www.hmsoft.cn
 */

public class Ajax {
	/******
	 * 是否已经成功登录,并在允许的时间内
	 */
	private boolean login = true;
	/****
	 * 请求是否成功
	 */
	private boolean success = true;

	/*****
	 * 单一对象
	 */
	private Object entity;

	/****
	 * 数组对象
	 */
	private List<?> array;

	/*****
	 * 分页对象
	 */
	private Pager page;

	/******
	 * 错误信息
	 */
	private String errorMsg;

	/***********
	 * 错误代码
	 */
	private int errorCode = 0;

	/********************
	 * 需要跳转的URL，优先
	 */
	private String url;

	/****
	 * map类型数据
	 */

	private Map<String, ?> map;
	
	
	/**********************
	 * 线程id，是否是一个后台线程，如果是，该信息为线程的编号
	 */
	private Integer threadId;

	public Ajax() {
	}
	
	public Ajax(FrameThread thread) {
		this.threadId = thread.getThread_id();
		this.entity = thread;
	}

	public Ajax(Object entity) {
		this.entity = entity;
	}

	public Ajax(List<?> array) {
		this.array = array;
	}

	public Ajax(Pager page) {
		this.page = page;
	}

	public Ajax(Map<String, Object> map) {
		this.map = map;
	}

	public Ajax(AppException error) {
		this.success = false;
		this.errorMsg = error.getMessage();
		this.errorCode = error.getErr_code();
	}

	public boolean isSuccess() {
		return success;
	}

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

	public Object getEntity() {
		return entity;
	}

	public void setEntity(Object entity) {
		this.entity = entity;
	}

	public List<?> getArray() {
		return array;
	}

	public void setArray(List<?> array) {
		this.array = array;
	}

	public Pager getPage() {
		return page;
	}

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

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public Map<String, ?> getMap() {
		return map;
	}

	public void setMap(Map<String, ?> map) {
		this.map = map;
	}

	public boolean isLogin() {
		return login;
	}

	public void setLogin(boolean login) {
		this.login = login;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(int errorCode) {
		this.errorCode = errorCode;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getThreadId() {
		return threadId;
	}

	public void setThreadId(Integer threadId) {
		this.threadId = threadId;
	}

	
	
}
