package com.bjtdba.utils;

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

public class ResponseUtil {

    public static Object ok() {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", 200);
        obj.put("message", "成功");
        return obj;
    }
    public static Object ok(Object data) {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", 200);
        obj.put("message", "成功");
        obj.put("data", data);
        return obj;
    }

    public static Object ok(String errmsg, Object data) {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", 200);
        obj.put("message", errmsg);
        obj.put("data", data);
        return obj;
    }

    public static Object fail() {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", -1);
        obj.put("message", "错误");
        return obj;
    }

    public static Object fail(String errmsg) {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", 400);
        obj.put("message", errmsg);
        return obj;
    }

    public static Object fail(int errno, String errmsg) {
        Map<String, Object> obj = new HashMap<String, Object>();
        obj.put("status", errno);
        obj.put("message", errmsg);
        return obj;
    }

    public static Object badArgument() {
        return fail(401, "参数不对");
    }

    public static Object badArgumentValue() {
        return fail(402, "参数值不对");
    }

    public static Object unlogin() {
        return fail(501, "请登录");
    }

    public static Object serious() {
        return fail(502, "系统内部错误");
    }

    public static Object unsupport() {
        return fail(503, "业务不支持");
    }

    public static Object updatedDateExpired() {
        return fail(504, "更新数据已经失效");
    }

    public static Object updatedDataFailed() {
        return fail(505, "更新数据失败");
    }

    public static Object unauthz() {
        return fail(506, "无操作权限");
    }
}
