package com.sckw.core.web.response;

import lombok.Data;

import java.io.Serializable;

/**
 * @desc:
 * @author: lt
 * @date: 2024/3/23 13:47
 */
@Data
public class HttpResult implements Serializable {

    private int code =200;
    private String msg = "success";
    private Object data;

    public static HttpResult error() {
        return error(500, "error");
    }

    public static HttpResult error(String msg) {
        return error(500, msg);
    }

    public static HttpResult error(int code, String msg) {
        HttpResult r = new HttpResult();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public static HttpResult error(String msg, Object data) {
        HttpResult r = new HttpResult();
        r.setCode(500);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static HttpResult error(int code, String msg, Object data) {
        HttpResult r = new HttpResult();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }


    public static HttpResult ok() {
        return new HttpResult();
    }

    public static HttpResult ok(String msg) {
        HttpResult r = new HttpResult();
        r.setMsg(msg);
        return r;
    }

    public static HttpResult ok(Object data) {
        HttpResult r = new HttpResult();
        r.setData(data);
        return r;
    }

    public static HttpResult ok(int code, String msg) {
        HttpResult r = new HttpResult();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }

    public static HttpResult ok(String msg, Object data) {
        HttpResult r = new HttpResult();
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static HttpResult ok(int code,String msg, Object data) {
        HttpResult r = new HttpResult();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
}
