瀏覽代碼

AI服务标签评论

qxy 2 月之前
父節點
當前提交
c833a38b52

+ 1 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/TagsMainVo.java

@@ -19,4 +19,5 @@ public class TagsMainVo extends TagsMain {
     private Integer evaluateNumber;
 
 
+
 }

+ 13 - 15
alien-entity/src/main/java/shop/alien/mapper/TagsMainMapper.java

@@ -40,23 +40,21 @@ public interface TagsMainMapper extends BaseMapper<TagsMain> {
     })
     int insertBatchTagsMain(List<TagsMain> tagsMainList);
 
-    @Select("\tSELECT\n" +
-            "\tmain.id,\n" +
-            "\tmain.tag_name,\n" +
-            "\tmain.store_id,\n" +
-            "\tmain.tag_type,\n" +
-            "\tCOUNT(main.id) AS evaluateNumber\n" +
+    @Select("SELECT\n" +
+            "    main.id,\n" +
+            "    main.tag_name,\n" +
+            "    main.store_id,\n" +
+            "    main.tag_type,\n" +
+            "    COUNT(DISTINCT synonym.comment_id) AS evaluateNumber\n" +
             "FROM\n" +
-            "\ttags_main main \n" +
-            "\tLEFT JOIN tags_synonym synonym ON main.id = synonym.main_tag_id \n" +
-            "\tAND synonym.tag_type = 0 \n" +
+            "    tags_main main\n" +
+            "    LEFT JOIN tags_synonym synonym \n" +
+            "        ON main.id = synonym.main_tag_id\n" +
+            "        AND synonym.delete_flag = 0  \n" +
             "WHERE\n" +
-            "\tmain.store_id = 685 \n" +
-            "\tAND main.delete_flag = 0\n" +
-            "\tAND synonym.delete_flag = 0\n" +
+            "    main.store_id = #{storeId} \n" +
+            "    AND main.delete_flag = 0\n" +
             "GROUP BY\n" +
-            "\tmain.id\t\n" +
-            "ORDER BY\n" +
-            "\tmain.id;")
+            "    main.id")
     List<TagsMainVo> getStoreEvaluateTags(int storeId);
 }

+ 5 - 4
alien-store/src/main/java/shop/alien/store/controller/StoreCommentController.java

@@ -43,12 +43,13 @@ public class StoreCommentController {
             @ApiImplicitParam(name = "commentLevel", value = "评论等级(0:全部, 1:好评, 2:中评, 3:差评)", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "days", value = "查询时间, 多少天前", dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "phoneId", value = "消息标识", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "userType", value = "评论的用户类型(0:商家, 其他:用户)", dataType = "String", paramType = "query")
+            @ApiImplicitParam(name = "userType", value = "评论的用户类型(0:商家, 其他:用户)", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "tagId", value = "标签id)", dataType = "Integer", paramType = "query")
     })
     @GetMapping("/getList")
-    public R<IPage<StoreCommentVo>> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType) {
-        log.info("StoreCommentController.getList?pageNum={}&pageSize={}&businessId={}&businessType={}&storeId={}&replyStatus={}&commentLevel={}&days={}&phoneId={}&userType={}", pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType);
-        return R.data(storeCommentService.getList(pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType));
+    public R<IPage<StoreCommentVo>> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType, Integer tagId) {
+        log.info("StoreCommentController.getList?pageNum={}&pageSize={}&businessId={}&businessType={}&storeId={}&replyStatus={}&commentLevel={}&days={}&phoneId={}&userType={}&tagId={}", pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType, tagId);
+        return R.data(storeCommentService.getList(pageNum, pageSize, businessId, businessType, storeId, replyStatus, commentLevel, days, phoneId, userType, tagId));
     }
 
     @ApiOperation("获取最新一条评论/评价")

+ 1 - 1
alien-store/src/main/java/shop/alien/store/service/StoreCommentService.java

@@ -33,7 +33,7 @@ public interface StoreCommentService extends IService<StoreComment> {
      * @param userType     评论的用户类型(0:商家, 其他:用户)
      * @return IPage<StoreComment>
      */
-    IPage<StoreCommentVo> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType);
+    IPage<StoreCommentVo> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType, Integer tagId);
 
     /**
      * 获取最新一条评论/评价

+ 13 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCommentServiceImpl.java

@@ -72,6 +72,8 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
 
     private final WebSocketProcess webSocketProcess;
 
+    private final TagsSynonymMapper tagsSynonymMapper;
+
     @Autowired
     private TextModerationUtil textModerationUtil;
 
@@ -91,7 +93,7 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
      * @return IPage<StoreComment>
      */
     @Override
-    public IPage<StoreCommentVo> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType) {
+    public IPage<StoreCommentVo> getList(Integer pageNum, Integer pageSize, Integer businessId, Integer businessType, Integer storeId, Integer replyStatus, Integer commentLevel, Integer days, String phoneId, Integer userType, Integer tagId) {
         IPage<StoreCommentVo> storeCommentIPage = new Page<>(pageNum, pageSize);
         QueryWrapper<StoreCommentVo> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq(null != businessId, "a.business_id", businessId);
@@ -142,6 +144,16 @@ public class StoreCommentServiceImpl extends ServiceImpl<StoreCommentMapper, Sto
             queryWrapper.notIn("a.id",businessIds);
         }
 
+        //根据标签id查询表签字表拿到评论ids
+        if(tagId !=null){
+            List<TagsSynonym> tagsSynonymList = tagsSynonymMapper.selectList(new LambdaQueryWrapper<TagsSynonym>().eq(TagsSynonym::getMainTagId,tagId));
+            if(CollectionUtils.isNotEmpty(tagsSynonymList)){
+                List<Integer> commentIdList = tagsSynonymList.stream().filter(synonym -> synonym != null)
+                        .map(TagsSynonym::getCommentId).filter(commentId -> commentId != null).collect(Collectors.toList());
+                queryWrapper.in("a.id",commentIdList);
+            }
+        }
+
         //先查询父级评论
         queryWrapper.isNull(businessType != 1, "a.reply_id").eq("a.delete_flag", 0).orderByDesc("a.created_time");
         IPage<StoreCommentVo> page = storeCommentMapper.getCommentPage(storeCommentIPage, queryWrapper);