package com.vincent.rsf.openApi.entity.dto;
|
|
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 r = new CommonResponse();
|
r.setCode(200);
|
r.setMsg("操作成功");
|
return r;
|
}
|
|
/** 8.2.3 格式:成功且 data 仅含 result */
|
public static CommonResponse okWithResult() {
|
return ok().setData(ResultData.success());
|
}
|
|
public static CommonResponse error(String msg) {
|
CommonResponse r = new CommonResponse();
|
r.setCode(500);
|
r.setMsg(msg != null ? msg : "操作失败");
|
r.setData(ResultData.fail());
|
return r;
|
}
|
|
}
|