/**
 * Copyright (c) 2020 wuchenxi
 * walter-blog is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * <p>
 * <p>
 * Mulan Permissive Software License，Version 2
 * <p>
 * Mulan Permissive Software License，Version 2 (Mulan PSL v2)
 * January 2020 http://license.coscl.org.cn/MulanPSL2
 */
package com.guwan.controller.login.response;

import lombok.Data;

import java.io.Serializable;

/**
 * 统一系统响应结果格式
 *
 * @author wuchenxi
 * @date 2020-08-08 10:07:03
 */
@Data
public class ResponseKit<T> implements Serializable {


    private int code;


    private String msg;


    private T data;

    private ResponseKit(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResponseKit(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public static <T> ResponseKit<T> success() {
        return new ResponseKit<T>(200, "操作成功！");
    }

    public static <T> ResponseKit<T> error(int code, String msg) {
        return new ResponseKit<T>(code, msg);
    }

    public static <T> ResponseKit<T> success(T data) {
        return new ResponseKit<T>(200, data);
    }

    private ResponseKit(){}
}
