package com.koobietech.eas.common.result;

import java.io.Serializable;

public class JsonResult implements Serializable {
    private boolean status = false;
    private String msg = "";
    private Object data = null;

    private Integer code = 200;

    /**
     * 成功
     * @return
     */
    public static JsonResult data(Object data , String message  ){
        JsonResult result = JsonResult.ok();
        result.setData(data);
        result.setMsg(message);
        return result;
    }

    /**
     * 成功
     * @return
     */
    public static JsonResult data(Object data , String message, Integer code ){
        JsonResult result = JsonResult.ok();
        result.setData(data);
        result.setMsg(message);
        result.setCode(code);
        return result;
    }

    /**
     * 成功
     * @return
     */
    public static JsonResult data( Object data  ){
        JsonResult result = JsonResult.ok();
        result.setData(data);
        return result;
    }

    /**
     * 成功
     * @return
     */
    public static JsonResult ok(){
        JsonResult result = new JsonResult();
        result.setStatus(true);
        result.setMsg("操作成功");
        return result;
    }

    /**
     * 成功
     * @return
     */
    public static JsonResult ok( String message ){
        JsonResult result = new JsonResult();
        result.setStatus(true);
        result.setMsg(message);
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail(){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setMsg("操作失败");
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail( int code){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setCode(code);
        result.setMsg("操作失败");
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail( Object data ){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setData(data);
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail( String message ){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setMsg(message);
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail( String message, int code ){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setCode(code);
        result.setMsg(message);
        return result;
    }

    /**
     * 失败
     * @return
     */
    public static JsonResult fail( Object data, String msg ){
        JsonResult result = new JsonResult();
        result.setStatus(false);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    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;
    }
}
