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; import lombok.experimental.Accessors; /** * @author Ryan * @date 2025/8/27 * @description: 通用响应结果 * @version 1.0 */ @Data @Accessors(chain = true) @ApiModel(value = "CommonResponse", description = "通用响应结果 ") public class CommonResponse { @ApiModelProperty("响应编码") private Integer code; @ApiModelProperty("响应消息") private String msg; @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; } }