package org.linlinjava.jz.hm.util;

import java.util.HashMap;
import java.util.Map;

public class HmResponseUtil {

	public static Map<String, Object> nullObj = new HashMap<String, Object>();

	public static final Object ok() {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", ok_n());

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}

	public static final Object ok(Object data) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", ok_d(data));

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}

	public static final Object ok(Object data, String errmsg, String errno) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", ok_d_e_o(data, errmsg, errno));

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}

	public static final Object fail(String errmsg) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", fail_o_e("-1",errmsg));

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}
	
	public static final Object fail() {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", fail_n());

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}
	
	public static final Object fail_null() {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", fail_o_e("-1","业务数据异常"));

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}
	
	public static final Object fail(String errno, String errmsg) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("success", true);
		obj.put("data", fail_o_e(errno,errmsg));

		obj.put("errorCode", "0");
		obj.put("errorMessage", "成功");
		return obj;
	}
	
	 

//	public static final Object error(String errorCode, String errorMessage) {
//		Map<String, Object> obj = new HashMap<String, Object>();
//		obj.put("success", false);
//		obj.put("data", nullObj);
//
//		obj.put("errorCode", errorCode);
//		obj.put("errorMessage", errorMessage);
//		return obj;
//	}

	
	//--------------构造成功
	private static final Object ok_n() {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("errno", 0);
		obj.put("errmsg", "成功");
		obj.put("data", "ok");
		return obj;
	}

	private static final Object ok_d(Object data) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("errno", 0);
		obj.put("errmsg", "成功");
		obj.put("data", data);
		return obj;
	}

	private static final Object ok_d_e_o(Object data, String errmsg, String errno) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("errno", errno);
		obj.put("errmsg", errmsg);
		obj.put("data", data);
		return obj;
	}

	
	//------------构造失败
	private static final Object fail_o_e(String errno, String errmsg) {
		Map<String, Object> obj = new HashMap<String, Object>();
		obj.put("errno", errno);
		obj.put("errmsg", errmsg);
		return obj;
	}

	private static final Object fail_n() {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("errno", -1);
        obj.put("errmsg", "错误");
        return obj;
    }
//
//    public static final Object fail(Object data) {
//        Map<String, Object> obj = new HashMap<String, Object>();
//        obj.put("errno", -1);
//        obj.put("errmsg", "错误");
//        obj.put("data", data);
//        return obj;
//    }
//

//    public static final Object fail400() {
//        return fail(400, "权限不够");
//    }
//    
//    public static final Object fail400(String str) {
//        return fail(400, str);
//    }
//    
//    public static final Object fail401() {
//        return fail(401, "请登录");
//    }
//
//    public static final Object unlogin(){
//        return fail401();
//    }
//
//    public static final Object fail402() {
//        return fail(402, "参数不对");
//    }
//
//    public static final Object badArgument(){
//        return fail402();
//    }
//
//    public static final Object fail403() {
//        return fail(403, "参数值不对");
//    }
//
//    public static final Object badArgumentValue(){
//        return fail403();
//    }
//
//    public static final Object fail501() {
//        return fail(501, "业务不支持");
//    }
//    
//    public static final Object fail501(String msg) {
//        return fail(501,msg);
//    }
//
//    public static final Object unsupport(){
//        return fail501();
//    }
//
//    public static final Object fail502() {
//        return fail(502, "系统内部错误");
//    }
//    
//    public static final Object fail502(String messge) {
//        return fail(502, messge);
//    }
//
//    public static final Object serious(){
//        return fail502();
//    }

}
