package cn.service.atv;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 *  自动测试平台专用： 接口返回数据格式
 */
public class Result<T> implements Serializable
{

    private static final Integer SC_OK_200 = 200;
    private static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
    /**访问权限认证未通过 510*/
    private static final Integer SC_JEECG_NO_AUTHZ=510;

    public static Map<String, Object> error500(String message) {
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("success",false);
        resultMap.put("code",SC_INTERNAL_SERVER_ERROR_500);
        resultMap.put("message",message);
        return resultMap;
    }
    public static Map<String, Object> error(int code, String msg) {
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("success",false);
        resultMap.put("code",code);
        resultMap.put("message",msg);
        return  resultMap ;
    }
    public static Map<String, Object> error(String msg) {
        return error(SC_INTERNAL_SERVER_ERROR_500, msg);
    }

    public static<T> Map<String, Object> OK(T data) {
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("success",true);
        resultMap.put("code",SC_OK_200);
        resultMap.put("result",data);
        return resultMap;
    }

    public static<T> Map<String, Object> OK(String msg, T data) {
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("success",true);
        resultMap.put("code",SC_OK_200);
        resultMap.put("result",data);
        resultMap.put("message",msg);
        return resultMap;
    }
}