package com.dgtly.system.util;


import com.dgtly.system.domain.Result;

/**
 * @Author: csz
 * @Date: 2020/6/7 23:28
 */
public class ResultUtil {

    public static <V> Result<V> error() {
        return error(500, "fail");
    }


    public static <V> Result<V> error(int code, String message) {
        Result<V> result = new Result<V>();
        result.setSuccess(false);
        result.setCode(code);
        result.setMessage(message);
        return result;
    }

//    ==============================================================================

    public static <V> Result<V> success() {
        return success(200, "success");
    }

    public static <V> Result<V> success(int code, String message) {
        return success(code, message, null);
    }


    public static <V> Result<V> success(V data) {
        return success(200, "success", data);
    }


    public static <V> Result<V> success(int code, String message, V data) {
        Result<V> result = new Result<V>();
        result.setSuccess(true);
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

}
