package com.cm.common.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * @ClassName: ErrorResult
 * @Description: 错误结果
 * @Author: WangGeng
 * @Date: 2019/3/2 3:37 PM
 * @Version: 1.0
 **/
@ApiModel
public class ErrorResult implements Serializable {

    @ApiModelProperty(name = "code", value = "错误编码", example = "40101")
    private Integer code;
    @ApiModelProperty(name = "msg", value = "错误信息", example = "查询失败")
    private String msg;
    @ApiModelProperty(name = "detail", value = "错误说明")
    private String detail;

    public ErrorResult() {
    }

    public ErrorResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

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

    public String getMsg() {
        return msg;
    }

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

    public String getDetail() {
        return detail == null ? "" : detail.trim();
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"code\":")
                .append(code);
        sb.append(",\"msg\":\"")
                .append(msg).append('\"');
        sb.append(",\"detail\":\"")
                .append(detail).append('\"');
        sb.append('}');
        return sb.toString();
    }
}
