feat: 添加基于路径参数的链接状态查询接口,增强参数验证和日志记录,保留兼容旧版的查询接口
This commit is contained in:
@@ -344,13 +344,35 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/{code}/status")
|
||||
@Operation(summary = "用户端获取链接状态(路径参数)", description = "根据链接编号获取链接状态,包含自动刷新逻辑,用于用户端页面。推荐使用此格式,更不容易丢失参数")
|
||||
public Mono<UserLinkStatusResponse> getUserLinkStatusByPath(
|
||||
@PathVariable("code") String code) {
|
||||
log.info("=== 用户端获取链接状态(路径参数) ===");
|
||||
log.info("code: {}", code);
|
||||
|
||||
// 验证参数
|
||||
if (code == null || code.trim().isEmpty()) {
|
||||
log.error("参数错误:code不能为空");
|
||||
return Mono.error(new IllegalArgumentException("参数错误:code不能为空"));
|
||||
}
|
||||
|
||||
return linkStatusService.getUserLinkStatus(null, code.trim())
|
||||
.doOnSuccess(response -> {
|
||||
log.info("用户端链接状态查询成功: status={}", response.getStatus());
|
||||
})
|
||||
.doOnError(error -> {
|
||||
log.error("用户端链接状态查询失败: {}", error.getMessage(), error);
|
||||
});
|
||||
}
|
||||
|
||||
@GetMapping("/status")
|
||||
@Operation(summary = "用户端获取链接状态", description = "根据链接ID或链接编号获取链接状态,包含自动刷新逻辑,用于用户端页面")
|
||||
public Mono<UserLinkStatusResponse> getUserLinkStatus(
|
||||
@Operation(summary = "用户端获取链接状态(查询参数,兼容旧版)", description = "根据链接编号获取链接状态,包含自动刷新逻辑。此接口保留用于兼容旧版本,推荐使用 /{code}/status 格式")
|
||||
public Mono<UserLinkStatusResponse> getUserLinkStatusByQuery(
|
||||
@RequestParam(value = "linkId", required = false) Long linkId,
|
||||
@RequestParam(value = "codeNo", required = false) String codeNo,
|
||||
@RequestParam(value = "code", required = false) String code) {
|
||||
log.info("=== 用户端获取链接状态 ===");
|
||||
log.info("=== 用户端获取链接状态(查询参数,兼容模式) ===");
|
||||
log.info("linkId: {}, codeNo: {}, code: {}", linkId, codeNo, code);
|
||||
|
||||
// 如果提供了code参数,则将其作为codeNo使用
|
||||
@@ -367,10 +389,10 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
|
||||
return linkStatusService.getUserLinkStatus(linkId, actualCodeNo)
|
||||
.doOnSuccess(response -> {
|
||||
log.info("用户端链接状态查询成功: status={}", response.getStatus());
|
||||
log.info("用户端链接状态查询成功(兼容模式): status={}", response.getStatus());
|
||||
})
|
||||
.doOnError(error -> {
|
||||
log.error("用户端链接状态查询失败: {}", error.getMessage(), error);
|
||||
log.error("用户端链接状态查询失败(兼容模式): {}", error.getMessage(), error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user