From b7ff8446a58d59e7df8a588104c231c7af7d8573 Mon Sep 17 00:00:00 2001 From: guyue <1721849008@qq.com> Date: 星期五, 11 七月 2025 14:31:15 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/main/java/com/linghu/controller/PlatformController.java | 2 +- src/main/java/com/linghu/service/KeywordService.java | 2 +- src/main/resources/mapper/keywordMapper.xml | 2 ++ src/main/java/com/linghu/controller/UserController.java | 4 ++-- src/main/java/com/linghu/controller/KeywordController.java | 25 +++++++++++++++++++++---- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/linghu/controller/KeywordController.java b/src/main/java/com/linghu/controller/KeywordController.java index 58358e0..cee397f 100644 --- a/src/main/java/com/linghu/controller/KeywordController.java +++ b/src/main/java/com/linghu/controller/KeywordController.java @@ -51,6 +51,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; @RestController @@ -154,12 +155,20 @@ if (isNow == 0) { List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, keyword.getNum() , typeId); + // 检查列表是否为空或只包含null元素 + boolean isValid = result != null && result.stream() + .anyMatch(Objects::nonNull); - return ResponseResult.success(result); + return isValid ? ResponseResult.success(result) + : ResponseResult.success(new ArrayList<>()); }else { List<PlatformProportionVO> result = keywordMapper.getResultByTypeId(keywordId, questionId, 1, typeId); + boolean isValid = result != null && result.stream() + .anyMatch(Objects::nonNull); - return ResponseResult.success(result); + return isValid ? ResponseResult.success(result) + : ResponseResult.success(new ArrayList<>()); + } } @@ -209,11 +218,19 @@ if (isNow == 0) { List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, keyword.getNum(), platformId); - return ResponseResult.success(result); + boolean isValid = result != null && result.stream() + .anyMatch(Objects::nonNull); + + return isValid ? ResponseResult.success(result) + : ResponseResult.success(new ArrayList<>()); } else { List<ResultListVO> result = keywordMapper.getResultByPlatformId(keywordId, questionId, 1, platformId); - return ResponseResult.success(result); + boolean isValid = result != null && result.stream() + .anyMatch(Objects::nonNull); + + return isValid ? ResponseResult.success(result) + : ResponseResult.success(new ArrayList<>()); } } diff --git a/src/main/java/com/linghu/controller/PlatformController.java b/src/main/java/com/linghu/controller/PlatformController.java index 6cc20bd..396a0fb 100644 --- a/src/main/java/com/linghu/controller/PlatformController.java +++ b/src/main/java/com/linghu/controller/PlatformController.java @@ -197,7 +197,7 @@ platformService.saveBatch(platforms); return ResponseResult.success("成功导入" + platforms.size() + "条数据"); } else { - return ResponseResult.error("没有有效数据可导入"); + return ResponseResult.success(); } } catch (Exception e) { diff --git a/src/main/java/com/linghu/controller/UserController.java b/src/main/java/com/linghu/controller/UserController.java index 76ccb70..9c77be3 100644 --- a/src/main/java/com/linghu/controller/UserController.java +++ b/src/main/java/com/linghu/controller/UserController.java @@ -43,7 +43,7 @@ public ResponseResult add(@RequestBody User user) { List<User> list = userService.list(new LambdaQueryWrapper<User>().eq(User::getUser_email, user.getUser_email())); if (list != null && list.size() > 0) { - return ResponseResult.error("该邮箱已存在"); + return ResponseResult.success("该邮箱已存在"); } user.setStatus("正常"); userService.save(user); @@ -66,7 +66,7 @@ .ne(User::getUser_id, user.getUser_id()) .eq(User::getUser_email, user.getUser_email())); if (list != null && list.size() > 0) { - return ResponseResult.error("该邮箱已存在"); + return ResponseResult.success("该邮箱已存在"); } userService.updateById(user); return ResponseResult.success(); diff --git a/src/main/java/com/linghu/service/KeywordService.java b/src/main/java/com/linghu/service/KeywordService.java index 1301fd5..a54cf4f 100644 --- a/src/main/java/com/linghu/service/KeywordService.java +++ b/src/main/java/com/linghu/service/KeywordService.java @@ -16,7 +16,7 @@ */ public interface KeywordService extends IService<Keyword> { - ResponseResult<KeywordStaticsListVO> statics(Integer keywordId, Integer questionId); + ResponseResult<KeywordStaticsListVO>statics(Integer keywordId, Integer questionId); ResponseResult<List<PlatformProportionVO>> getResultByTypeId(Integer keywordId, Integer questionId, Integer typeId); diff --git a/src/main/resources/mapper/keywordMapper.xml b/src/main/resources/mapper/keywordMapper.xml index 87e4837..eb69865 100644 --- a/src/main/resources/mapper/keywordMapper.xml +++ b/src/main/resources/mapper/keywordMapper.xml @@ -93,6 +93,7 @@ <if test="typeId != null"> AND p.type_id = #{typeId} </if> + GROUP BY t.type_name,p.platform_name ORDER BY r.repetition_num DESC </select> @@ -117,6 +118,7 @@ <if test="platformId != null"> AND r.platform_id = #{platformId} </if> + ORDER BY r.repetition_num, r.create_time DESC -- Gitblit v1.7.1