|
|
@@ -19,38 +19,51 @@
|
|
|
<result column="agree" property="agree"/>
|
|
|
<result column="disagree" property="disagree"/>
|
|
|
</resultMap>
|
|
|
-
|
|
|
- <!-- 分页查询聊天记录(含评价信息) -->
|
|
|
- <select id="pageQueryWithReview" resultMap="AiMessageWithReviewMap">
|
|
|
- SELECT
|
|
|
- m.*,
|
|
|
- COALESCE(sum(r.agree, 0)) AS agree,
|
|
|
- COALESCE(sum(r.disagree, 0)) AS disagree
|
|
|
- FROM ai_messages m
|
|
|
- LEFT JOIN ai_messages_review r ON r.ai_message_id = m.id
|
|
|
- ${ew.customSqlSegment}
|
|
|
- group by m.id
|
|
|
- </select>
|
|
|
-
|
|
|
<select id="queryList" resultMap="AiMessageWithReviewMap">
|
|
|
SELECT
|
|
|
- m.*,
|
|
|
- IFNULL(sum(r.agree), 0) AS agree,
|
|
|
- IFNULL(sum(r.disagree), 0) AS disagree
|
|
|
+ m.id,
|
|
|
+ m.query,
|
|
|
+ m.answer,
|
|
|
+ IFNULL(sum(r.agree), 0) AS agree,
|
|
|
+ IFNULL(sum(r.disagree), 0) AS disagree
|
|
|
FROM ai_messages m
|
|
|
- LEFT JOIN ai_messages_review r ON r.ai_message_id = m.id
|
|
|
- ${ew.customSqlSegment}
|
|
|
- group by m.id
|
|
|
+ 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}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY m.id
|
|
|
+ <if test="queryField != null and queryField != ''">
|
|
|
+ HAVING ${queryField} > 0
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
- <select id="getTotal" resultType="java.lang.Integer">
|
|
|
- SELECT count(DISTINCT m.id) as total
|
|
|
+ <select id="getTotal" resultType="java.lang.Integer">
|
|
|
+ SELECT COUNT(DISTINCT id)
|
|
|
+ FROM (SELECT
|
|
|
+ m.id,
|
|
|
+ m.query,
|
|
|
+ m.answer,
|
|
|
+ IFNULL(sum(r.agree), 0) AS agree,
|
|
|
+ IFNULL(sum(r.disagree), 0) AS disagree
|
|
|
FROM ai_messages m
|
|
|
- LEFT JOIN ai_messages_review r ON r.ai_message_id = m.id
|
|
|
- ${ew.customSqlSegment}
|
|
|
-
|
|
|
+ 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}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY m.id
|
|
|
+ <if test="queryField != null and queryField != ''">
|
|
|
+ HAVING ${queryField} > 0
|
|
|
+ </if>) total
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
</mapper>
|