From d74af8a07fa30f70c7839933ffdddaa51cc57a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=92?= Date: Sun, 7 Sep 2025 17:25:16 +0800 Subject: [PATCH] 1 --- .../controller/jd/JDInnerController.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/cn/van/business/controller/jd/JDInnerController.java b/src/main/java/cn/van/business/controller/jd/JDInnerController.java index 2997376..9b7d232 100644 --- a/src/main/java/cn/van/business/controller/jd/JDInnerController.java +++ b/src/main/java/cn/van/business/controller/jd/JDInnerController.java @@ -1,5 +1,7 @@ package cn.van.business.controller.jd; +import cn.van.business.model.pl.TaobaoComment; +import cn.van.business.repository.TaobaoCommentRepository; import cn.van.business.util.JDProductService; import cn.van.business.util.JDUtil; import cn.van.business.repository.CommentRepository; @@ -31,12 +33,14 @@ public class JDInnerController { private final JDProductService jdProductService; private final JDUtil jdUtil; private final CommentRepository commentRepository; + private final TaobaoCommentRepository taobaoCommentRepository; @Autowired - public JDInnerController(JDProductService jdProductService, JDUtil jdUtil, CommentRepository commentRepository) { + public JDInnerController(JDProductService jdProductService, JDUtil jdUtil, CommentRepository commentRepository, TaobaoCommentRepository taobaoCommentRepository) { this.jdProductService = jdProductService; this.jdUtil = jdUtil; this.commentRepository = commentRepository; + this.taobaoCommentRepository = taobaoCommentRepository; } @PostMapping("/generatePromotionContent") @@ -116,7 +120,7 @@ public class JDInnerController { // 获取本地可用的京东评论并统计 List available = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 1); List used = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 0); - + canUseCommentCount = available.size(); usedCommentCount = used.size(); allCommentCount = canUseCommentCount + usedCommentCount; @@ -125,11 +129,11 @@ public class JDInnerController { HashMap tbMap = jdUtil.getProductTypeMapForTB(); String taobaoProductId = tbMap.getOrDefault(productId, productId); // 注意:这里需要注入TaobaoCommentRepository,暂时注释掉淘宝统计部分 - // List availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1); - // List usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0); - // canUseTbCommentCount = availableTbComments.size(); - // usedTbCommentCount = usedTbComments.size(); - // allTbCommentCount = canUseTbCommentCount + usedTbCommentCount; + List availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1); + List usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0); + canUseTbCommentCount = availableTbComments.size(); + usedTbCommentCount = usedTbComments.size(); + allTbCommentCount = canUseTbCommentCount + usedTbCommentCount; List candidates = !available.isEmpty() ? available : used; if (candidates.isEmpty()) { @@ -157,7 +161,7 @@ public class JDInnerController { stats.put("used", usedCommentCount); stats.put("available", canUseCommentCount); stats.put("total", allCommentCount); - stats.put("statisticsText", + stats.put("statisticsText", "京东评论统计:\n" + "型号 " + productType + "\n" + "新增:" + addCommentCount + "\n" +