rsf-open-api/src/main/java/com/vincent/rsf/openApi/entity/dto/CommonResponse.java
@@ -1,5 +1,6 @@
package com.vincent.rsf.openApi.entity.dto;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -25,4 +26,35 @@
    @ApiModelProperty("响应结果")
    private Object data;
    /**
     * 成功响应
     */
    public static CommonResponse ok() {
        CommonResponse response = new CommonResponse();
        response.setCode(200);
        response.setMsg("操作成功");
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("result", "SUCCESS");
        response.setData(jsonObject);
        return response;
    }
    public static CommonResponse ok(Object data) {
        CommonResponse response = new CommonResponse();
        response.setCode(200);
        response.setMsg("操作成功");
        response.setData(data);
        return response;
    }
    /**
     * 失败响应
     */
    public static CommonResponse error(String msg) {
        CommonResponse response = new CommonResponse();
        response.setCode(500);
        response.setMsg(msg);
        return response;
    }
}