package org.fouram.core.util;

import org.fouram.core.base.model.PageData;

public class AppUtil {

	public interface ResultConstant {
		/** 成功 */
		String SUCCESS = "01";
		/** 错误 */
		String ERROR = "999";
		/** 无效 */
		String NO_TOKEN = "998";
		/** 错误 */
		String TOKEN_ERR_MSG = "TOKEN无效";
		String WEB_ERR_MSG = "系统异常";
	}

	public static PageData success() {
		PageData result = new PageData();
		result.put("result", ResultConstant.SUCCESS);
		return result;
	}

	public static PageData success(Object data, String msg) {
		PageData result = success();
		result.put("data", data);
		result.put("msg", msg);
		return result;
	}

	public static PageData error(String code, String msg) {
		PageData result = success();
		result.put("result", code);
		result.put("msg", msg);
		return result;
	}

	public static PageData error(String msg) {
		PageData result = new PageData();
		result.put("result", ResultConstant.ERROR);
		result.put("msg", msg);
		return result;
	}

	public static PageData error() {
		PageData result = new PageData();
		result.put("result", ResultConstant.ERROR);
		result.put("msg", ResultConstant.WEB_ERR_MSG);
		return result;
	}
}
