Sfoglia il codice sorgente

修复ai消息好评过滤

183207892172 1 mese fa
parent
commit
aa673b421c

+ 5 - 2
java/storlead-knowledge/storlead-knowledge-biz/src/main/java/com/storlead/knowledge/mapper/AiMessageMapper.java

@@ -21,8 +21,11 @@ public interface AiMessageMapper extends MyBaseMapper<AiMessageEntity> {
 
     List<AiMessageWithReviewVO> queryList(  @Param("page") Page<AiMessageEntity> page,
                                             @Param("keyword") String keyword,
-                                            @Param("queryField") String queryField);
+                                            @Param("queryField") String queryField,
+                                            @Param("userId") Long userId
+                                            );
 
     Integer getTotal(  @Param("keyword") String keyword,
-                       @Param("queryField") String queryField);
+                       @Param("queryField") String queryField,
+                       @Param("userId") Long userId);
 }

+ 3 - 6
java/storlead-knowledge/storlead-knowledge-biz/src/main/java/com/storlead/knowledge/service/impl/AiMessageServiceImpl.java

@@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.storlead.framework.mybatis.service.impl.MyBaseServiceImpl;
+import com.storlead.framework.util.LoginUserUtil;
 import com.storlead.knowledge.entity.AiMessageEntity;
-import com.storlead.knowledge.entity.AiMessageReviewEntity;
 import com.storlead.knowledge.mapper.AiMessageMapper;
 import com.storlead.knowledge.pojo.dto.QueryPageDTO;
 import com.storlead.knowledge.pojo.vo.AiMessageWithReviewVO;
-import com.storlead.knowledge.pojo.vo.AiTrainingVO;
 import com.storlead.knowledge.service.AiMessageService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
@@ -54,18 +53,16 @@ public class AiMessageServiceImpl extends MyBaseServiceImpl<AiMessageMapper, AiM
         String queryField = StringUtils.isNotBlank(page.getQuery()) ? page.getQuery() : null;
 
         List<AiMessageWithReviewVO> list =
-                baseMapper.queryList(pageParam, page.getKeyword(), queryField);
+                baseMapper.queryList(pageParam, page.getKeyword(), queryField, LoginUserUtil.getLoginUser().getId());
 
         Integer total =
-                baseMapper.getTotal(page.getKeyword(), queryField);
+                baseMapper.getTotal(page.getKeyword(), queryField,LoginUserUtil.getLoginUser().getId());
 
         Page<AiMessageWithReviewVO> result =
                 new Page<>(page.getPageIndex(), page.getPageSize());
 
         result.setRecords(list);
         result.setTotal(total);
-        result.setPages(page.getPageSize());
-        result.setCurrent(page.getPageIndex());
         return result;
     }
 

+ 7 - 2
java/storlead-knowledge/storlead-knowledge-biz/src/main/resources/mapper/AiMessageMapper.xml

@@ -18,6 +18,8 @@
         <result column="created_at" property="createdAt"/>
         <result column="agree" property="agree"/>
         <result column="disagree" property="disagree"/>
+        <result column="my_agree" property="myAgree"/>
+        <result column="my_disagree" property="myDisagree"/>
     </resultMap>
     <select id="queryList" resultMap="AiMessageWithReviewMap">
         SELECT
@@ -25,14 +27,17 @@
         m.query,
         m.answer,
         IFNULL(sum(r.agree), 0) AS agree,
-        IFNULL(sum(r.disagree), 0) AS disagree
+        IFNULL(sum(r.disagree), 0) AS disagree,
+        MAX(CASE WHEN r.owner_by = 1 THEN r.agree    ELSE 0 END) AS my_agree,
+        MAX(CASE WHEN r.owner_by = 1 THEN r.disagree ELSE 0 END) AS my_disagree
         FROM ai_messages m
         LEFT JOIN ai_messages_review r ON r.ai_message_id = m.id
         <where>
             <if test="keyword != null and keyword != ''">
                 AND (
                 m.query LIKE CONCAT('%', #{keyword}, '%')
-                OR m.answer LIKE CONCAT('%', #{keyword}, '%')
+                OR m.answer LIKE CONCAT('%', #{keyword},
+                '%')
                 )
             </if>
         </where>

+ 8 - 0
java/storlead-knowledge/storlead-knowledge-core/src/main/java/com/storlead/knowledge/pojo/vo/AiMessageWithReviewVO.java

@@ -21,4 +21,12 @@ public class AiMessageWithReviewVO extends AiMessageEntity {
 
     @ApiModelProperty(value = "差评数")
     private Integer disagree;
+
+    @ApiModelProperty(value = "我的点赞")
+    private Integer myAgree;
+
+    @ApiModelProperty(value = "我的差评")
+    private Integer myDisagree;
+
+
 }