feat: 改进设备任务更新服务,集成游戏完成检测,优化状态处理逻辑
This commit is contained in:
@@ -57,8 +57,8 @@ public class LinkController {
|
||||
@Operation(summary = "查询链接列表", description = "分页查询用户生成的链接列表,支持按状态、批次ID等条件过滤和排序")
|
||||
public Mono<LinkListResponse> getLinkList(@Valid LinkListRequest request, Authentication authentication) {
|
||||
log.info("=== 开始查询链接列表 ===");
|
||||
log.info("请求参数: page={}, pageSize={}, status={}, batchId={}, isExpired={}, sortBy={}, sortDir={}",
|
||||
request.getPage(), request.getPageSize(), request.getStatus(),
|
||||
log.debug("请求参数: page={}, pageSize={}, status={}, batchId={}, isExpired={}, sortBy={}, sortDir={}",
|
||||
request.getPage(), request.getPageSize(), request.getStatus(),
|
||||
request.getBatchId(), request.getIsExpired(), request.getSortBy(), request.getSortDir());
|
||||
|
||||
if (authentication == null) {
|
||||
@@ -66,20 +66,19 @@ public class LinkController {
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Authentication为空"));
|
||||
}
|
||||
|
||||
log.info("认证用户: {}", authentication.getName());
|
||||
log.debug("已通过认证的请求");
|
||||
|
||||
// 获取用户ID
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
log.error("认证失败:Claims为空");
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
Long agentId = claims.get("userId", Long.class);
|
||||
String userType = claims.get("userType", String.class);
|
||||
|
||||
log.info("用户信息: agentId={}, userType={}", agentId, userType);
|
||||
log.debug("已解析用户信息");
|
||||
|
||||
if (agentId == null) {
|
||||
log.error("=== 无法获取用户ID ===");
|
||||
@@ -101,23 +100,17 @@ public class LinkController {
|
||||
@Operation(summary = "生成链接批次", description = "生成指定数量的链接批次。所有用户(管理员和代理商)都只能为自己生成链接,代理用户生成链接时会扣除积分,管理员生成链接时不扣除积分")
|
||||
public Mono<LinkGenerateResponse> generateLinks(@Valid @RequestBody LinkGenerateRequest request,
|
||||
Authentication authentication) {
|
||||
log.info("=== 开始处理链接生成请求 ===");
|
||||
log.info("请求参数: times={}, linkCount={}",
|
||||
request.getTimes(), request.getLinkCount());
|
||||
log.info("开始处理链接生成请求");
|
||||
log.debug("请求参数: times={}, linkCount={}", request.getTimes(), request.getLinkCount());
|
||||
|
||||
log.info("=== 开始检查认证信息 ===");
|
||||
log.info("Authentication: {}", authentication);
|
||||
log.debug("开始检查认证信息");
|
||||
|
||||
if (authentication == null) {
|
||||
log.error("=== 认证失败:Authentication为空 ===");
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Authentication为空"));
|
||||
}
|
||||
|
||||
log.info("Authentication获取成功: {}", authentication);
|
||||
log.info("Authentication是否已认证: {}", authentication.isAuthenticated());
|
||||
log.info("Authentication的principal: {}", authentication.getPrincipal());
|
||||
log.info("Authentication的authorities: {}", authentication.getAuthorities());
|
||||
log.info("Authentication的details: {}", authentication.getDetails());
|
||||
log.debug("认证上下文可用,且已认证: {}", authentication.isAuthenticated());
|
||||
|
||||
if (!authentication.isAuthenticated()) {
|
||||
log.error("=== 认证失败:Authentication未通过验证 ===");
|
||||
@@ -125,48 +118,36 @@ public class LinkController {
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Authentication未通过验证"));
|
||||
}
|
||||
|
||||
log.info("=== 认证验证通过 ===");
|
||||
log.debug("认证验证通过");
|
||||
|
||||
// 从认证对象中获取用户信息
|
||||
log.info("开始解析Claims信息");
|
||||
log.debug("开始解析Claims信息");
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
log.error("认证失败:Claims为空");
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
log.info("Claims获取成功,开始解析用户信息");
|
||||
log.info("Claims内容: {}", claims);
|
||||
log.info("Claims的subject: {}", claims.getSubject());
|
||||
log.info("Claims的issuedAt: {}", claims.getIssuedAt());
|
||||
log.info("Claims的expiration: {}", claims.getExpiration());
|
||||
log.debug("Claims获取成功,开始解析用户信息");
|
||||
|
||||
Long operatorId = claims.get("userId", Long.class);
|
||||
String operatorType = claims.get("userType", String.class);
|
||||
String username = claims.get("username", String.class);
|
||||
|
||||
log.info("解析出的用户信息 - operatorId: {}, operatorType: {}, username: {}",
|
||||
operatorId, operatorType, username);
|
||||
log.debug("用户信息已解析");
|
||||
|
||||
if (operatorId == null || operatorType == null) {
|
||||
log.error("=== 认证失败:缺少必要的用户信息 ===");
|
||||
log.error("operatorId: {}, operatorType: {}, username: {}", operatorId, operatorType, username);
|
||||
log.error("Claims中所有键: {}", claims.keySet());
|
||||
log.error("认证失败:缺少必要的用户信息");
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:缺少必要的用户信息"));
|
||||
}
|
||||
|
||||
log.info("=== 用户认证信息完整,开始处理业务逻辑 ===");
|
||||
log.info("操作者信息: operatorId={}, operatorType={}, username={}",
|
||||
operatorId, operatorType, username);
|
||||
log.info("业务参数: times={}, linkCount={}",
|
||||
request.getTimes(), request.getLinkCount());
|
||||
log.debug("用户认证信息完整,开始处理业务逻辑");
|
||||
log.debug("业务参数: times={}, linkCount={}", request.getTimes(), request.getLinkCount());
|
||||
|
||||
return linkGenerationService.generateLinks(operatorId, operatorType,
|
||||
request.getTimes(), request.getLinkCount())
|
||||
.map(result -> {
|
||||
log.info("链接生成成功,batchId: {}, 扣除积分: {}, 过期时间: {}",
|
||||
result.getBatchId(), result.getNeedPoints(), result.getExpireAt());
|
||||
log.info("链接生成成功");
|
||||
LinkGenerateResponse response = new LinkGenerateResponse();
|
||||
response.setBatchId(result.getBatchId());
|
||||
response.setDeductPoints(result.getNeedPoints());
|
||||
@@ -194,7 +175,7 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
@@ -237,7 +218,7 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
@@ -287,7 +268,7 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
@@ -333,7 +314,7 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
Claims claims = (Claims) authentication.getDetails();
|
||||
if (claims == null) {
|
||||
log.error("=== 认证失败:Claims为空 ===");
|
||||
log.error("Authentication details: {}", authentication.getDetails());
|
||||
|
||||
return Mono.error(new IllegalArgumentException("用户未认证:Claims为空"));
|
||||
}
|
||||
|
||||
@@ -511,5 +492,3 @@ public Mono<Boolean> deleteLink(@PathVariable("codeNo") String codeNo, Authentic
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user