package com.qy.worksheetsystem.model;

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

/**
 * @author he
 * @date 2022/2/28
 * @description  用于返回前端json数据的工具类
 */
public class MessageResultV2 extends MessageResult {

    // 状态码
    private int code;
    // 提示信息
    private String msg;

    // 封装有效数据
    private Object data = new Object();

    public static MessageResultV2 success() {
        MessageResultV2 result = new MessageResultV2();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }

    public static MessageResultV2 fail() {
        MessageResultV2 result = new MessageResultV2();
        result.setCode(400);
        result.setMsg("fail");
        return result;
    }

    public static MessageResultV2 noPermission() {
        MessageResultV2 result = new MessageResultV2();
        result.setCode(401);
        result.setMsg("no permission");
        return result;
    }

    public static MessageResultV2 error() {
        MessageResultV2 result = new MessageResultV2();
        result.setCode(500);
        result.setMsg("error");
        return result;
    }

    public static MessageResultV2 error(String error) {
        MessageResultV2 result = new MessageResultV2();
        result.setCode(404);
        result.setMsg(error);
        return result;
    }

    public static MessageResultV2 code(int code){
        MessageResultV2 result = new MessageResultV2();
        result.setCode(code);
        result.setMsg("exception");
        return result;
    }



    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}