From 9a34ef1f3c2aea28705939eb1dc32c28f1222ad9 Mon Sep 17 00:00:00 2001
From: guyue <1721849008@qq.com>
Date: 星期四, 10 七月 2025 18:41:48 +0800
Subject: [PATCH] 修改

---
 src/main/java/com/linghu/mapper/UserMapper.java            |    2 +-
 src/main/java/com/linghu/controller/CollectController.java |   24 ++++++++++++------------
 src/main/java/com/linghu/controller/KeywordController.java |    2 ++
 src/main/resources/mapper/UserMapper.xml                   |    2 +-
 4 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/main/java/com/linghu/controller/CollectController.java b/src/main/java/com/linghu/controller/CollectController.java
index 09acdce..9a7eac3 100644
--- a/src/main/java/com/linghu/controller/CollectController.java
+++ b/src/main/java/com/linghu/controller/CollectController.java
@@ -226,6 +226,7 @@
                }, 1) // 限制并发数为1,确保顺序执行
                .collectList() // 收集所有批次的响应
                .flatMap(responses ->
+
                        saveKeywordTasks(keywordId, responses) // 保存关联关系
                                .thenReturn(responses) // 返回原始响应
                );
@@ -272,11 +273,12 @@
                 .bodyToMono(new ParameterizedTypeReference<SearchTaskResponse>() {})
                 .flatMap(taskResponse -> {
                     if (taskResponse != null && taskResponse.getTask_id() != null) {
+
                         // 使用 Reactor 的方式更新数据库
                         return Mono.fromRunnable(() -> {
                                     LambdaUpdateWrapper<Keyword> updateWrapper = new LambdaUpdateWrapper<>();
                                     updateWrapper.eq(Keyword::getKeyword_id, batchRequest.getKeyword_id());
-                                    updateWrapper.set(Keyword::getStatus, "Submitted");
+                                    updateWrapper.set(Keyword::getStatus, "submitted");
                                     updateWrapper.set(Keyword::getTask_id, taskResponse.getTask_id());
                                     keywordService.update(updateWrapper);
                                 }).subscribeOn(Schedulers.boundedElastic()) // 在弹性线程池执行
@@ -342,9 +344,9 @@
                 .map(data -> ResponseResult.success(data))
                 .onErrorResume(e -> {
                     if (e.getMessage().contains("任务不存在")) {
-                        return Mono.just(ResponseResult.error(404, "任务不存在"));
+                        return Mono.just(ResponseResult.error(200, "任务不存在"));
                     } else if (e.getMessage().contains("无法取消")) {
-                        return Mono.just(ResponseResult.error(400, "任务已完成,无法取消"));
+                        return Mono.just(ResponseResult.error(200, "任务已完成,无法取消"));
                     }
                     return Mono.just(ResponseResult.error(500, "取消任务失败: " + e.getMessage()));
                 });
@@ -453,20 +455,12 @@
     private Mono<Void> updateQuestionAndReference(TaskResultResponse result) {
         return Mono.fromRunnable(() -> {
             try {
-                // 1. 更新关键词状态
-                LambdaUpdateWrapper<Keyword> keywordUpdate = new LambdaUpdateWrapper<>();
-                keywordUpdate.eq(Keyword::getTask_id, result.getTask_id())
-                        .set(Keyword::getStatus, "completed");
-                keywordService.update(keywordUpdate);
-
+                // 1. 根据KeywordTask更新关键词状态
                 // 查询关键词ID
-
                 LambdaQueryWrapper<KeywordTask> keywordTaskWrapper = new LambdaQueryWrapper<>();
                 keywordTaskWrapper.eq(KeywordTask::getTask_id, result.getTask_id());
                 KeywordTask keywordTask = keywordTaskService.getOne(keywordTaskWrapper);
 
-//                LambdaQueryWrapper<Keyword> keywordQuery = new LambdaQueryWrapper<>();
-//                keywordQuery.eq(Keyword::getTask_id, keywordTask.getTask_id());
                 Keyword keyword = keywordService.getById(keywordTask.getKeyword_id());
 
                 if (keyword == null) {
@@ -475,6 +469,8 @@
                     throw new Exception("未找到关联的关键词,task_id: " + result.getTask_id());
 //                    return;
                 }
+                keyword.setStatus("completed");
+                keywordService.updateById(keyword);
 
                 // 2. 批量查询所有问题
                 LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>();
@@ -536,6 +532,8 @@
                                                     reference.setUrl(ref.getUrl());
                                                     reference.setDomain(ref.getDomain());
                                                     reference.setNum(finalMaxNumByKeywordId);
+                                                    reference.setTask_id(result.getTask_id());
+                                                    reference.setKeyword_id(keyword.getKeyword_id());
                                                     //域名和平台id映射
                                                     reference.setCreate_time(LocalDateTime.now());
                                                     Platform platform = platformService.getPlatformByDomain(reference.getDomain());
@@ -621,6 +619,7 @@
     }
 
     @GetMapping("/health")
+    @ApiOperation("健康检查")
     public Mono<HealthResponse> checkThirdPartyHealth() {
         return webClient.get()
                 .uri(baseUrl + "/health") // 假设第三方健康检查接口路径为/health
@@ -634,6 +633,7 @@
      * 查询服务器资源
      */
     @GetMapping("/server/resource")
+    @ApiOperation(value = "查询服务器资源")
     public Mono<ServerResourceResponse> getServerResource() {
         return webClient.get()
                 .uri(baseUrl + "/api/v1/system/resources")
diff --git a/src/main/java/com/linghu/controller/KeywordController.java b/src/main/java/com/linghu/controller/KeywordController.java
index 80f1dde..0128509 100644
--- a/src/main/java/com/linghu/controller/KeywordController.java
+++ b/src/main/java/com/linghu/controller/KeywordController.java
@@ -477,5 +477,7 @@
             return ResponseResult.error("导入失败:" + e.getMessage());
         }
     }
+    //根据关键词id查询任务id
+
 
 }
diff --git a/src/main/java/com/linghu/mapper/UserMapper.java b/src/main/java/com/linghu/mapper/UserMapper.java
index 15f4b54..50ac193 100644
--- a/src/main/java/com/linghu/mapper/UserMapper.java
+++ b/src/main/java/com/linghu/mapper/UserMapper.java
@@ -14,7 +14,7 @@
 */
 public interface UserMapper extends BaseMapper<User> {
 
-    Page<User> getPage(Page<UserPageVO> page, @Param("sectionalizationId") Integer sectionalizationId, @Param("status") String status);
+    Page<UserPageVO> getPage(Page<UserPageVO> page, @Param("sectionalizationId") Integer sectionalizationId, @Param("status") String status);
 }
 
 
diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml
index 50cefe9..cbb1688 100644
--- a/src/main/resources/mapper/UserMapper.xml
+++ b/src/main/resources/mapper/UserMapper.xml
@@ -18,7 +18,7 @@
         user_id,user_name,user_email,
         password,phone,sectionalization_id,status
     </sql>
-    <select id="getPage" resultType="com.linghu.model.entity.User">
+    <select id="getPage" resultType="com.linghu.model.vo.UserPageVO">
         SELECT
             u.user_id,
             u.user_name,

--
Gitblit v1.7.1