| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.fs.fastGpt.mapper.FastgptChatQuestionStatisticsMapper">
- <resultMap type="FastgptChatQuestionStatistics" id="FastgptChatQuestionStatisticsResult">
- <result property="id" column="id" />
- <result property="questionCategory" column="question_category" />
- <result property="source" column="source" />
- <result property="contentSummary" column="content_summary" />
- <result property="simhash" column="simhash" />
- <result property="frequency" column="frequency" />
- <result property="isResolve" column="is_resolve" />
- <result property="questionId" column="question_id" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <sql id="selectFastgptChatQuestionStatisticsVo">
- select id, question_category, source, content_summary, simhash, frequency, is_resolve, question_id, create_time, update_time from fastgpt_chat_question_statistics
- </sql>
- <select id="selectFastgptChatQuestionStatisticsList" parameterType="FastgptChatQuestionStatistics" resultMap="FastgptChatQuestionStatisticsResult">
- <include refid="selectFastgptChatQuestionStatisticsVo"/>
- <where>
- <if test="questionCategory != null "> and question_category = #{questionCategory}</if>
- <if test="source != null "> and source = #{source}</if>
- <if test="contentSummary != null and contentSummary != ''"> and content_summary = #{contentSummary}</if>
- <if test="frequency != null "> and frequency = #{frequency}</if>
- <if test="isResolve != null "> and is_resolve = #{isResolve}</if>
- <if test="questionId != null "> and question_id = #{questionId}</if>
- </where>
- </select>
- <select id="selectFastgptChatQuestionStatisticsById" parameterType="Long" resultMap="FastgptChatQuestionStatisticsResult">
- <include refid="selectFastgptChatQuestionStatisticsVo"/>
- where id = #{id}
- </select>
- <insert id="insertFastgptChatQuestionStatistics" parameterType="FastgptChatQuestionStatistics" useGeneratedKeys="true" keyProperty="id">
- insert into fastgpt_chat_question_statistics
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="questionCategory != null">question_category,</if>
- <if test="source != null">source,</if>
- <if test="contentSummary != null">content_summary,</if>
- <if test="simhash != null">simhash,</if>
- <if test="frequency != null">frequency,</if>
- <if test="isResolve != null">is_resolve,</if>
- <if test="questionId != null">question_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="questionCategory != null">#{questionCategory},</if>
- <if test="source != null">#{source},</if>
- <if test="contentSummary != null">#{contentSummary},</if>
- <if test="simhash != null">#{simhash},</if>
- <if test="frequency != null">#{frequency},</if>
- <if test="isResolve != null">#{isResolve},</if>
- <if test="questionId != null">#{questionId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updateFastgptChatQuestionStatistics" parameterType="FastgptChatQuestionStatistics">
- update fastgpt_chat_question_statistics
- <trim prefix="SET" suffixOverrides=",">
- <if test="questionCategory != null">question_category = #{questionCategory},</if>
- <if test="source != null">source = #{source},</if>
- <if test="contentSummary != null">content_summary = #{contentSummary},</if>
- <if test="simhash != null">simhash = #{simhash},</if>
- <if test="frequency != null">frequency = #{frequency},</if>
- <if test="isResolve != null">is_resolve = #{isResolve},</if>
- <if test="questionId != null">question_id = #{questionId},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteFastgptChatQuestionStatisticsById" parameterType="Long">
- delete from fastgpt_chat_question_statistics where id = #{id}
- </delete>
- <delete id="deleteFastgptChatQuestionStatisticsByIds" parameterType="String">
- delete from fastgpt_chat_question_statistics where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="selectBestMatchBySimhash" resultMap="FastgptChatQuestionStatisticsResult">
- SELECT s.*,
- BIT_COUNT(s.simhash ^ #{simhash}) AS dist
- FROM fastgpt_chat_question_statistics s
- WHERE s.simhash IS NOT NULL
- HAVING dist <= #{threshold}
- ORDER BY dist ASC, s.frequency DESC, s.id ASC
- LIMIT 1
- </select>
- <select id="selectCandidatesBySimhash" resultMap="FastgptChatQuestionStatisticsResult">
- SELECT s.*,
- BIT_COUNT(s.simhash ^ #{simhash}) AS dist
- FROM fastgpt_chat_question_statistics s
- WHERE s.simhash IS NOT NULL
- HAVING dist <= #{threshold}
- ORDER BY dist ASC, s.frequency DESC, s.id DESC
- LIMIT #{limit}
- </select>
- <update id="incrementFrequencyById">
- update fastgpt_chat_question_statistics
- set frequency = frequency + 1,
- update_time = #{updateTime}
- where id = #{id}
- </update>
- <select id="selectFirstByQuestionCategory" resultMap="FastgptChatQuestionStatisticsResult">
- <include refid="selectFastgptChatQuestionStatisticsVo"/>
- where question_category = #{questionCategory}
- order by id asc
- limit 1
- </select>
- </mapper>
|