删除swagger侵入式代码 , 删除demo
This commit is contained in:
@@ -22,13 +22,6 @@
|
||||
<artifactId>tashow-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
|
||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package com.tashow.cloud.infraapi.api.config;
|
||||
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 参数配置")
|
||||
/** RPC 服务 - 参数配置 */
|
||||
public interface ConfigApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/config";
|
||||
|
||||
@GetMapping(PREFIX + "/get-value-by-key")
|
||||
@Operation(summary = "根据参数键查询参数值")
|
||||
CommonResult<String> getConfigValueByKey(@RequestParam("key") String key);
|
||||
String PREFIX = ApiConstants.PREFIX + "/config";
|
||||
|
||||
/** 根据参数键查询参数值 */
|
||||
@GetMapping(PREFIX + "/get-value-by-key")
|
||||
CommonResult<String> getConfigValueByKey(@RequestParam("key") String key);
|
||||
}
|
||||
|
||||
@@ -1,62 +1,58 @@
|
||||
package com.tashow.cloud.infraapi.api.file;
|
||||
|
||||
import com.tashow.cloud.infraapi.api.file.dto.FileCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infraapi.api.file.dto.FileCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 文件")
|
||||
/** RPC 服务 - 文件 */
|
||||
public interface FileApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/file";
|
||||
String PREFIX = ApiConstants.PREFIX + "/file";
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content) {
|
||||
return createFile(null, null, content);
|
||||
}
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(byte[] content) {
|
||||
return createFile(null, null, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(String path, byte[] content) {
|
||||
return createFile(null, path, content);
|
||||
}
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(String path, byte[] content) {
|
||||
return createFile(null, path, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param name 原文件名称
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(@RequestParam("name") String name,
|
||||
@RequestParam("path") String path,
|
||||
@RequestParam("content") byte[] content) {
|
||||
return createFile(new FileCreateReqDTO().setName(name).setPath(path).setContent(content)).getCheckedData();
|
||||
}
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "保存文件,并返回文件的访问路径")
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
/**
|
||||
* 保存文件,并返回文件的访问路径
|
||||
*
|
||||
* @param name 原文件名称
|
||||
* @param path 文件路径
|
||||
* @param content 文件内容
|
||||
* @return 文件路径
|
||||
*/
|
||||
default String createFile(
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("path") String path,
|
||||
@RequestParam("content") byte[] content) {
|
||||
return createFile(new FileCreateReqDTO().setName(name).setPath(path).setContent(content))
|
||||
.getCheckedData();
|
||||
}
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
/** 保存文件,并返回文件的访问路径 */
|
||||
CommonResult<String> createFile(@Valid @RequestBody FileCreateReqDTO createReqDTO);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
package com.tashow.cloud.infraapi.api.file.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
@Schema(description = "RPC 服务 - 文件创建 Request DTO")
|
||||
/** RPC 服务 - 文件创建 Request DTO */
|
||||
@Data
|
||||
public class FileCreateReqDTO {
|
||||
|
||||
@Schema(description = "原文件名称", example = "xxx.png")
|
||||
private String name;
|
||||
/** 原文件名称 */
|
||||
private String name;
|
||||
|
||||
@Schema(description = "文件路径", example = "xxx.png")
|
||||
private String path;
|
||||
|
||||
@Schema(description = "文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "文件内容不能为空")
|
||||
private byte[] content;
|
||||
/** 文件路径 */
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 文件内容
|
||||
*/
|
||||
@NotEmpty(message = "文件内容不能为空")
|
||||
private byte[] content;
|
||||
}
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
package com.tashow.cloud.infraapi.api.logger;
|
||||
|
||||
import com.tashow.cloud.infraapi.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infraapi.api.logger.dto.ApiAccessLogCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - API 访问日志")
|
||||
/** RPC 服务 - API 访问日志 */
|
||||
public interface ApiAccessLogApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/api-access-log";
|
||||
String PREFIX = ApiConstants.PREFIX + "/api-access-log";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建 API 访问日志")
|
||||
CommonResult<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建 API 访问日志
|
||||
*
|
||||
* @param createDTO 访问日志 DTO
|
||||
*/
|
||||
@Async
|
||||
default void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
|
||||
createApiAccessLog(createDTO).checkError();
|
||||
}
|
||||
@PostMapping(PREFIX + "/create")
|
||||
/** 创建 API 访问日志 */
|
||||
CommonResult<Boolean> createApiAccessLog(@Valid @RequestBody ApiAccessLogCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建 API 访问日志
|
||||
*
|
||||
* @param createDTO 访问日志 DTO
|
||||
*/
|
||||
@Async
|
||||
default void createApiAccessLogAsync(ApiAccessLogCreateReqDTO createDTO) {
|
||||
createApiAccessLog(createDTO).checkError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,31 @@
|
||||
package com.tashow.cloud.infraapi.api.logger;
|
||||
|
||||
import com.tashow.cloud.infraapi.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.infraapi.api.logger.dto.ApiErrorLogCreateReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - API 异常日志")
|
||||
/** RPC 服务 - API 异常日志 */
|
||||
public interface ApiErrorLogApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/api-error-log";
|
||||
String PREFIX = ApiConstants.PREFIX + "/api-error-log";
|
||||
|
||||
@PostMapping(PREFIX + "/create")
|
||||
@Operation(summary = "创建 API 异常日志")
|
||||
CommonResult<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建 API 异常日志
|
||||
*
|
||||
* @param createDTO 异常日志 DTO
|
||||
*/
|
||||
@Async
|
||||
default void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
|
||||
createApiErrorLog(createDTO).checkError();
|
||||
}
|
||||
@PostMapping(PREFIX + "/create")
|
||||
/** 创建 API 异常日志 */
|
||||
CommonResult<Boolean> createApiErrorLog(@Valid @RequestBody ApiErrorLogCreateReqDTO createDTO);
|
||||
|
||||
/**
|
||||
* 【异步】创建 API 异常日志
|
||||
*
|
||||
* @param createDTO 异常日志 DTO
|
||||
*/
|
||||
@Async
|
||||
default void createApiErrorLogAsync(ApiErrorLogCreateReqDTO createDTO) {
|
||||
createApiErrorLog(createDTO).checkError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,63 +1,81 @@
|
||||
package com.tashow.cloud.infraapi.api.logger.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "RPC 服务 - API 访问日志创建 Request DTO")
|
||||
/** RPC 服务 - API 访问日志创建 Request DTO */
|
||||
@Data
|
||||
public class ApiAccessLogCreateReqDTO {
|
||||
|
||||
@Schema(description = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
/** 链路追踪编号 */
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long userId;
|
||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer userType;
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "system-server")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
/** 用户编号" */
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String requestMethod;
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String requestUrl;
|
||||
@Schema(description = "请求参数")
|
||||
private String requestParams;
|
||||
@Schema(description = "响应结果")
|
||||
private String responseBody;
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String userIp;
|
||||
@Schema(description = "浏览器 UserAgent", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
/** 用户类型" */
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "操作模块", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品模块")
|
||||
private String operateModule;
|
||||
@Schema(description = "操作名", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品新增")
|
||||
private String operateName;
|
||||
@Schema(description = "操作分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer operateType; // 参见 OperateTypeEnum 枚举
|
||||
/** 应用名" */
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
@Schema(description = "开始时间",requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "开始请求时间不能为空")
|
||||
private LocalDateTime beginTime;
|
||||
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "结束请求时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
@Schema(description = "执行时长,单位:毫秒", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "执行时长不能为空")
|
||||
private Integer duration;
|
||||
@Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "错误码不能为空")
|
||||
private Integer resultCode;
|
||||
@Schema(description = "结果提示")
|
||||
private String resultMsg;
|
||||
/** 请求方法名" */
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
/** 请求地址", example = "/xxx/yyy */
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
/** 请求参数 */
|
||||
private String requestParams;
|
||||
|
||||
/** 响应结果 */
|
||||
private String responseBody;
|
||||
|
||||
/** 用户 IP" */
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String userIp;
|
||||
|
||||
/** 浏览器 UserAgent" */
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
|
||||
/** 操作模块", example = "商品模块 */
|
||||
private String operateModule;
|
||||
|
||||
/** 操作名", example = "商品新增 */
|
||||
private String operateName;
|
||||
|
||||
/** 操作分类" */
|
||||
private Integer operateType; // 参见 OperateTypeEnum 枚举
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@NotNull(message = "开始请求时间不能为空")
|
||||
private LocalDateTime beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@NotNull(message = "结束请求时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 执行时长,单位:毫秒
|
||||
*/
|
||||
@NotNull(message = "执行时长不能为空")
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 结果码
|
||||
*/
|
||||
@NotNull(message = "错误码不能为空")
|
||||
private Integer resultCode;
|
||||
|
||||
/** 结果提示 */
|
||||
private String resultMsg;
|
||||
}
|
||||
|
||||
@@ -1,68 +1,99 @@
|
||||
package com.tashow.cloud.infraapi.api.logger.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "RPC 服务 - API 错误日志创建 Request DTO")
|
||||
/** RPC 服务 - API 错误日志创建 Request DTO */
|
||||
@Data
|
||||
public class ApiErrorLogCreateReqDTO {
|
||||
|
||||
@Schema(description = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
|
||||
private String traceId;
|
||||
/** 链路追踪编号 */
|
||||
private String traceId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long userId;
|
||||
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer userType;
|
||||
@Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "system-server")
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
/** 用户编号" */
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String requestMethod;
|
||||
@Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String requestUrl;
|
||||
@Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String requestParams;
|
||||
@Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String userIp;
|
||||
@Schema(description = "浏览器 UserAgent", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
/** 用户类型" */
|
||||
private Integer userType;
|
||||
|
||||
@Schema(description = "异常时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常时间不能为空")
|
||||
private LocalDateTime exceptionTime;
|
||||
@Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常名不能为空")
|
||||
private String exceptionName;
|
||||
@Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的类全名不能为空")
|
||||
private String exceptionClassName;
|
||||
@Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的类文件不能为空")
|
||||
private String exceptionFileName;
|
||||
@Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的方法名不能为空")
|
||||
private String exceptionMethodName;
|
||||
@Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常发生的方法所在行不能为空")
|
||||
private Integer exceptionLineNumber;
|
||||
@Schema(description = "异常的栈轨迹异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常的栈轨迹不能为空")
|
||||
private String exceptionStackTrace;
|
||||
@Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常导致的根消息不能为空")
|
||||
private String exceptionRootCauseMessage;
|
||||
@Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "异常导致的消息不能为空")
|
||||
private String exceptionMessage;
|
||||
/** 应用名" */
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
|
||||
/** 请求方法名" */
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String requestMethod;
|
||||
|
||||
/** 请求地址", example = "/xxx/yyy */
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String requestUrl;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String requestParams;
|
||||
|
||||
/** 用户 IP" */
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String userIp;
|
||||
|
||||
/** 浏览器 UserAgent" */
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
|
||||
/**
|
||||
* 异常时间
|
||||
*/
|
||||
@NotNull(message = "异常时间不能为空")
|
||||
private LocalDateTime exceptionTime;
|
||||
|
||||
/**
|
||||
* 异常名
|
||||
*/
|
||||
@NotNull(message = "异常名不能为空")
|
||||
private String exceptionName;
|
||||
|
||||
/**
|
||||
* 异常发生的类全名
|
||||
*/
|
||||
@NotNull(message = "异常发生的类全名不能为空")
|
||||
private String exceptionClassName;
|
||||
|
||||
/**
|
||||
* 异常发生的类文件
|
||||
*/
|
||||
@NotNull(message = "异常发生的类文件不能为空")
|
||||
private String exceptionFileName;
|
||||
|
||||
/**
|
||||
* 异常发生的方法名
|
||||
*/
|
||||
@NotNull(message = "异常发生的方法名不能为空")
|
||||
private String exceptionMethodName;
|
||||
|
||||
/**
|
||||
* 异常发生的方法所在行
|
||||
*/
|
||||
@NotNull(message = "异常发生的方法所在行不能为空")
|
||||
private Integer exceptionLineNumber;
|
||||
|
||||
/**
|
||||
* 异常的栈轨迹异常的栈轨迹
|
||||
*/
|
||||
@NotNull(message = "异常的栈轨迹不能为空")
|
||||
private String exceptionStackTrace;
|
||||
|
||||
/**
|
||||
* 异常导致的根消息
|
||||
*/
|
||||
@NotNull(message = "异常导致的根消息不能为空")
|
||||
private String exceptionRootCauseMessage;
|
||||
|
||||
/**
|
||||
* 异常导致的消息
|
||||
*/
|
||||
@NotNull(message = "异常导致的消息不能为空")
|
||||
private String exceptionMessage;
|
||||
}
|
||||
|
||||
@@ -1,75 +1,82 @@
|
||||
package com.tashow.cloud.infraapi.api.websocket;
|
||||
|
||||
import com.tashow.cloud.infraapi.api.websocket.dto.WebSocketSendReqDTO;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import com.tashow.cloud.common.pojo.CommonResult;
|
||||
import com.tashow.cloud.common.util.json.JsonUtils;
|
||||
import com.tashow.cloud.infraapi.api.websocket.dto.WebSocketSendReqDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import com.tashow.cloud.infraapi.enums.ApiConstants;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - WebSocket 发送器的") // 对 WebSocketMessageSender 进行封装,提供给其它模块使用
|
||||
/** RPC 服务 - WebSocket 发送器的 */
|
||||
// 对 WebSocketMessageSender 进行封装,提供给其它模块使用
|
||||
public interface WebSocketSenderApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/websocket";
|
||||
String PREFIX = ApiConstants.PREFIX + "/websocket";
|
||||
|
||||
@PostMapping(PREFIX + "/send")
|
||||
@Operation(summary = "发送 WebSocket 消息")
|
||||
CommonResult<Boolean> send(@Valid @RequestBody WebSocketSendReqDTO message);
|
||||
@PostMapping(PREFIX + "/send")
|
||||
/** 发送 WebSocket 消息 */
|
||||
CommonResult<Boolean> send(@Valid @RequestBody WebSocketSendReqDTO message);
|
||||
|
||||
/**
|
||||
* 发送消息给指定用户
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param userId 用户编号
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(Integer userType, Long userId, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO().setUserType(userType).setUserId(userId)
|
||||
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
|
||||
}
|
||||
/**
|
||||
* 发送消息给指定用户
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param userId 用户编号
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(Integer userType, Long userId, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO()
|
||||
.setUserType(userType)
|
||||
.setUserId(userId)
|
||||
.setMessageType(messageType)
|
||||
.setMessageContent(messageContent))
|
||||
.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息给指定用户类型
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(Integer userType, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO().setUserType(userType)
|
||||
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
|
||||
}
|
||||
/**
|
||||
* 发送消息给指定用户类型
|
||||
*
|
||||
* @param userType 用户类型
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(Integer userType, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO()
|
||||
.setUserType(userType)
|
||||
.setMessageType(messageType)
|
||||
.setMessageContent(messageContent))
|
||||
.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息给指定 Session
|
||||
*
|
||||
* @param sessionId Session 编号
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(String sessionId, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO().setSessionId(sessionId)
|
||||
.setMessageType(messageType).setMessageContent(messageContent)).checkError();
|
||||
}
|
||||
/**
|
||||
* 发送消息给指定 Session
|
||||
*
|
||||
* @param sessionId Session 编号
|
||||
* @param messageType 消息类型
|
||||
* @param messageContent 消息内容,JSON 格式
|
||||
*/
|
||||
default void send(String sessionId, String messageType, String messageContent) {
|
||||
send(new WebSocketSendReqDTO()
|
||||
.setSessionId(sessionId)
|
||||
.setMessageType(messageType)
|
||||
.setMessageContent(messageContent))
|
||||
.checkError();
|
||||
}
|
||||
|
||||
default void sendObject(Integer userType, Long userId, String messageType, Object messageContent) {
|
||||
send(userType, userId, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
default void sendObject(
|
||||
Integer userType, Long userId, String messageType, Object messageContent) {
|
||||
send(userType, userId, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
|
||||
default void sendObject(Integer userType, String messageType, Object messageContent) {
|
||||
send(userType, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
|
||||
default void sendObject(String sessionId, String messageType, Object messageContent) {
|
||||
send(sessionId, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
default void sendObject(Integer userType, String messageType, Object messageContent) {
|
||||
send(userType, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
|
||||
default void sendObject(String sessionId, String messageType, Object messageContent) {
|
||||
send(sessionId, messageType, JsonUtils.toJsonString(messageContent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
package com.tashow.cloud.infraapi.api.websocket.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
@Schema(description = "RPC 服务 - WebSocket 消息发送 Request DTO")
|
||||
/** RPC 服务 - WebSocket 消息发送 Request DTO */
|
||||
@Data
|
||||
public class WebSocketSendReqDTO {
|
||||
|
||||
@Schema(description = "Session 编号", example = "abc")
|
||||
private String sessionId;
|
||||
@Schema(description = "用户编号", example = "1024")
|
||||
private Long userId;
|
||||
@Schema(description = "用户类型", example = "1")
|
||||
private Integer userType;
|
||||
/** Session 编号 */
|
||||
private String sessionId;
|
||||
|
||||
@Schema(description = "消息类型", example = "demo-message")
|
||||
@NotEmpty(message = "消息类型不能为空")
|
||||
private String messageType;
|
||||
@Schema(description = "消息内容", example = "{\"name\":\"李四\"}}")
|
||||
@NotEmpty(message = "消息内容不能为空")
|
||||
private String messageContent;
|
||||
/** 用户编号 */
|
||||
private Long userId;
|
||||
|
||||
/** 用户类型 */
|
||||
private Integer userType;
|
||||
|
||||
/** 消息类型 */
|
||||
@NotEmpty(message = "消息类型不能为空")
|
||||
private String messageType;
|
||||
|
||||
/** 消息内容 */
|
||||
@NotEmpty(message = "消息内容不能为空")
|
||||
private String messageContent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user