(improvement)(chat) Split chat into three modules: server, api, and core. (#594)

This commit is contained in:
lexluo09
2024-01-04 16:56:49 +08:00
committed by GitHub
parent 0858c13365
commit 023e84c420
337 changed files with 2407 additions and 2715 deletions

View File

@@ -0,0 +1,303 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.AgentDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDO">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="description" jdbcType="VARCHAR" property="description" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="examples" jdbcType="VARCHAR" property="examples" />
<result column="config" jdbcType="VARCHAR" property="config" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="enable_search" jdbcType="INTEGER" property="enableSearch" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, description, status, examples, config, created_by, created_at, updated_by,
updated_at, enable_search
</sql>
<select id="selectByExample" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_agent
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from s2_agent
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from s2_agent
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDO">
insert into s2_agent (id, name, description,
status, examples, config,
created_by, created_at, updated_by,
updated_at, enable_search)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{examples,jdbcType=VARCHAR}, #{config,jdbcType=VARCHAR},
#{createdBy,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR},
#{updatedAt,jdbcType=TIMESTAMP}, #{enableSearch,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDO">
insert into s2_agent
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="description != null">
description,
</if>
<if test="status != null">
status,
</if>
<if test="examples != null">
examples,
</if>
<if test="config != null">
config,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="enableSearch != null">
enable_search,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="examples != null">
#{examples,jdbcType=VARCHAR},
</if>
<if test="config != null">
#{config,jdbcType=VARCHAR},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="enableSearch != null">
#{enableSearch,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDOExample" resultType="java.lang.Long">
select count(*) from s2_agent
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update s2_agent
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=VARCHAR},
</if>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.examples != null">
examples = #{record.examples,jdbcType=VARCHAR},
</if>
<if test="record.config != null">
config = #{record.config,jdbcType=VARCHAR},
</if>
<if test="record.createdBy != null">
created_by = #{record.createdBy,jdbcType=VARCHAR},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedBy != null">
updated_by = #{record.updatedBy,jdbcType=VARCHAR},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.enableSearch != null">
enable_search = #{record.enableSearch,jdbcType=INTEGER},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update s2_agent
set id = #{record.id,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR},
description = #{record.description,jdbcType=VARCHAR},
status = #{record.status,jdbcType=INTEGER},
examples = #{record.examples,jdbcType=VARCHAR},
config = #{record.config,jdbcType=VARCHAR},
created_by = #{record.createdBy,jdbcType=VARCHAR},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_by = #{record.updatedBy,jdbcType=VARCHAR},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
enable_search = #{record.enableSearch,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDO">
update s2_agent
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="examples != null">
examples = #{examples,jdbcType=VARCHAR},
</if>
<if test="config != null">
config = #{config,jdbcType=VARCHAR},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="enableSearch != null">
enable_search = #{enableSearch,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.AgentDO">
update s2_agent
set name = #{name,jdbcType=VARCHAR},
description = #{description,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
examples = #{examples,jdbcType=VARCHAR},
config = #{config,jdbcType=VARCHAR},
created_by = #{createdBy,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
enable_search = #{enableSearch,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@@ -0,0 +1,97 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.ChatConfigMapper">
<resultMap id="chaConfigDO"
type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatConfigDO">
<id column="id" property="id"/>
<result column="model_id" property="modelId"/>
<result column="chat_detail_config" property="chatDetailConfig"/>
<result column="chat_agg_config" property="chatAggConfig"/>
<result column="recommended_questions" property="recommendedQuestions"/>
<result column="status" property="status"/>
<result column="llm_examples" property="llmExamples"/>
<result column="created_by" property="createdBy"/>
<result column="updated_by" property="updatedBy"/>
<result column="created_at" property="createdAt"/>
<result column="updated_at" property="updatedAt"/>
</resultMap>
<insert id="addConfig"
parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatConfigDO"
useGeneratedKeys="true" keyProperty="id">
insert into s2_chat_config
(
model_id, `chat_detail_config`, chat_agg_config, recommended_questions, status, llm_examples, created_by, updated_by, created_at, updated_at
)
values
(
#{modelId}, #{chatDetailConfig}, #{chatAggConfig}, #{recommendedQuestions}, #{status}, #{llmExamples}, #{createdBy}, #{updatedBy}, #{createdAt}, #{updatedAt}
)
</insert>
<update id="editConfig">
update s2_chat_config
<set>
`updated_at` = #{updatedAt} ,
<if test="chatDetailConfig != null and chatDetailConfig != ''">
`chat_detail_config` = #{chatDetailConfig} ,
</if>
<if test="chatAggConfig != null and chatAggConfig != ''">
chat_agg_config = #{chatAggConfig} ,
</if>
<if test="recommendedQuestions != null and recommendedQuestions != ''">
recommended_questions = #{recommendedQuestions} ,
</if>
<if test="status != null and status != ''">
status = #{status} ,
</if>
<if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy} ,
</if>
<if test="llmExamples != null and llmExamples != ''">
llm_examples = #{llmExamples} ,
</if>
</set>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
<if test="modelId != null and modelId != ''">
and model_id = #{modelId}
</if>
</where>
</update>
<select id="search" resultMap="chaConfigDO">
select *
from s2_chat_config
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
<if test="modelId != null and modelId != ''">
and model_id = #{modelId}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
</where>
</select>
<select id="fetchConfigByModelId" resultMap="chaConfigDO">
select *
from s2_chat_config
where model_id = #{modelId}
and status != 3
order by updated_at desc
limit 1
</select>
</mapper>

View File

@@ -0,0 +1,30 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.ChatContextMapper">
<resultMap id="ChatContextDO"
type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatContextDO">
<id column="chat_id" property="chatId"/>
<result column="modified_at" property="modifiedAt"/>
<result column="user" property="user"/>
<result column="query_text" property="queryText"/>
<result column="semantic_parse" property="semanticParse"/>
<!--<result column="ext_data" property="extData"/>-->
</resultMap>
<select id="getContextByChatId" resultMap="ChatContextDO">
select *
from s2_chat_context where chat_id=#{chatId} limit 1
</select>
<insert id="addContext" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatContextDO" >
insert into s2_chat_context (chat_id,user,query_text,semantic_parse) values (#{chatId}, #{user},#{queryText}, #{semanticParse})
</insert>
<update id="updateContext">
update s2_chat_context set query_text=#{queryText},semantic_parse=#{semanticParse} where chat_id=#{chatId}
</update>
</mapper>

View File

@@ -0,0 +1,118 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.ChatMapper">
<resultMap id="IntelligentConversion" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO">
<id column="chat_id" property="chatId"/>
<result column="agent_id" property="agentId"/>
<result column="chat_name" property="chatName"/>
<result column="create_time" property="createTime"/>
<result column="last_time" property="lastTime"/>
<result column="creator" property="creator"/>
<result column="last_question" property="lastQuestion"/>
<result column="is_delete" property="isDelete"/>
<result column="is_top" property="isTop"/>
</resultMap>
<select id="getAll" resultMap="IntelligentConversion">
select *
from s2_chat
where creator = #{creator}
and is_delete = 0
<if test="agentId != null">
and agent_id = #{agentId}
</if>
order by is_top desc, last_time desc
</select>
<update id="updateConversionIsTop">
update s2_chat
set is_top=#{isTop}
where chat_id = #{chatId}
</update>
<update id="updateChatName">
update s2_chat
set chat_name=#{chatName},
last_time=#{lastTime}
where chat_id = #{chatId}
and creator = #{creator}
</update>
<update id="updateLastQuestion">
update s2_chat
set last_question = #{lastQuestion},
last_time = #{lastTime}
where chat_id = #{chatId}
</update>
<insert id="createChat" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatDO">
insert into s2_chat
(agent_id, chat_name, create_time, last_time, creator, last_question, is_delete, is_top)
values (#{agentId}, #{chatName}, #{createTime}, #{lastTime}, #{creator}, #{lastQuestion}, #{isDelete}, #{isTop})
</insert>
<update id="deleteChat">
update s2_chat
set is_delete=1
where chat_id = #{chatId}
and creator = #{userName}
</update>
<resultMap id="IntelligentQuery" type="com.tencent.supersonic.chat.server.persistence.dataobject.QueryDO">
<id column="id" property="id"/>
<result column="question_id" property="questionId"/>
<result column="create_time" property="createTime"/>
<result column="time" property="time"/>
<result column="user_name" property="userName"/>
<result column="question" property="question"/>
<result column="query_result" property="queryResults"/>
<result column="state" property="state"/>
<result column="data_content" property="dataContent"/>
<result column="name" property="name"/>
<result column="query_type" property="queryType"/>
<result column="is_deleted" property="isDeleted"/>
<result column="module" property="module"/>
<result column="aggregator" property="aggregator"/>
<result column="top_num" property="topNum"/>
<result column="start_time" property="startTime"/>
<result column="end_time" property="endTime"/>
<result column="query_sql" property="querySql"/>
<result column="score" property="score"/>
<result column="feedback" property="feedback"/>
<result column="chat_id" property="chatId"/>
</resultMap>
<update id="updateFeedback" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.QueryDO">
update s2_chat_query
set score=#{score},
feedback=#{feedback}
where question_id = #{id}
</update>
<insert id="createQuery" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.QueryDO"
useGeneratedKeys="true" keyProperty="id">
insert into s2_chat_query
(question_id, create_time, user_name, question, query_result, time, state, data_content, name, query_type,
is_deleted, module, chat_id, aggregator, top_num, start_time, end_time, query_sql, columns, main_entity, score,
feedback)
values (#{questionId}, #{createTime}, #{userName}, #{question}, #{queryResults}, #{time}, #{state},
#{dataContent}, #{name}, #{queryType}, #{isDeleted}, #{module}, #{chatId}, #{aggregator}, #{topNum},
#{startTime}, #{endTime}, #{querySql}, #{QueryColumn}, #{EntityInfo}, #{score}, #{feedback})
</insert>
<select id="queryInfo" resultMap="IntelligentQuery">
select *
from s2_chat_query
where user_name = #{userName}
and chat_id = #{chatId}
and is_deleted = 0
order by time DESC, query_type DESC
</select>
</mapper>

View File

@@ -0,0 +1,49 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.ChatParseMapper">
<resultMap id="ChatParse" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatParseDO">
<id column="question_id" property="questionId"/>
<result column="chat_id" property="chatId"/>
<result column="parse_id" property="parseId"/>
<result column="create_time" property="createTime"/>
<result column="query_text" property="queryText"/>
<result column="user_name" property="userName"/>
<result column="parse_info" property="parseInfo"/>
<result column="is_candidate" property="isCandidate"/>
</resultMap>
<insert id="batchSaveParseInfo" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatParseDO">
insert into s2_chat_parse
(question_id, chat_id, parse_id, create_time, query_text, user_name, parse_info,is_candidate)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.questionId}, #{item.chatId}, #{item.parseId}, #{item.createTime}, #{item.queryText}, #{item.userName}, #{item.parseInfo}, #{item.isCandidate})
</foreach>
</insert>
<update id="updateParseInfo" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatParseDO">
update s2_chat_parse
set parse_info = #{parseInfo}
where question_id = #{questionId} and parse_id = #{parseId}
</update>
<select id="getParseInfo" resultMap="ChatParse">
select *
from s2_chat_parse
where question_id = #{questionId} and parse_id = #{parseId} limit 1
</select>
<select id="getParseInfoList" resultMap="ChatParse">
select *
from s2_chat_parse
where question_id in
<foreach item="questionId" index="index" collection="list" open="(" separator="," close=")">
#{questionId}
</foreach>
</select>
</mapper>

View File

@@ -0,0 +1,126 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.ChatQueryDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO">
<id column="question_id" jdbcType="BIGINT" property="questionId" />
<result column="agent_id" jdbcType="INTEGER" property="agentId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="query_state" jdbcType="INTEGER" property="queryState" />
<result column="chat_id" jdbcType="BIGINT" property="chatId" />
<result column="score" jdbcType="INTEGER" property="score" />
<result column="feedback" jdbcType="VARCHAR" property="feedback" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO">
<result column="query_text" jdbcType="LONGVARCHAR" property="queryText" />
<result column="query_result" jdbcType="LONGVARCHAR" property="queryResult" />
<result column="similar_queries" jdbcType="LONGVARCHAR" property="similarQueries"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
question_id, agent_id, create_time, user_name, query_state, chat_id, score, feedback
</sql>
<sql id="Blob_Column_List">
query_text, query_result, similar_queries
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_chat_query
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs">
select * from s2_chat_query
where question_id = #{questionId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_chat_query
where question_id = #{questionId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO" useGeneratedKeys="true" keyProperty="questionId">
insert into s2_chat_query (agent_id, create_time, user_name,
query_state, chat_id, score,
feedback, query_text, query_result, similar_queries
)
values (#{agentId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{userName,jdbcType=VARCHAR},
#{queryState,jdbcType=INTEGER}, #{chatId,jdbcType=BIGINT}, #{score,jdbcType=INTEGER},
#{feedback,jdbcType=VARCHAR}, #{queryText,jdbcType=LONGVARCHAR}, #{queryResult,jdbcType=LONGVARCHAR},
#{similarQueries, jdbcType=LONGVARCHAR}
)
</insert>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO">
update s2_chat_query
<set>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="userName != null">
user_name = #{userName,jdbcType=VARCHAR},
</if>
<if test="queryState != null">
query_state = #{queryState,jdbcType=INTEGER},
</if>
<if test="chatId != null">
chat_id = #{chatId,jdbcType=BIGINT},
</if>
<if test="score != null">
score = #{score,jdbcType=INTEGER},
</if>
<if test="feedback != null">
feedback = #{feedback,jdbcType=VARCHAR},
</if>
<if test="queryText != null">
query_text = #{queryText,jdbcType=LONGVARCHAR},
</if>
<if test="queryResult != null">
query_result = #{queryResult,jdbcType=LONGVARCHAR},
</if>
<if test="similarQueries != null">
similar_queries = #{similarQueries,jdbcType=LONGVARCHAR},
</if>
</set>
where question_id = #{questionId,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -0,0 +1,53 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.DictConfMapper">
<resultMap id="DictConfPO"
type="com.tencent.supersonic.chat.server.persistence.dataobject.DictConfDO">
<id column="id" property="id"/>
<result column="model_id" property="modelId"/>
<result column="dim_value_infos" property="dimValueInfos"/>
<result column="created_at" property="createdAt"/>
<result column="updated_at" property="updatedAt"/>
<result column="created_by" property="createdBy"/>
<result column="updated_by" property="updatedBy"/>
</resultMap>
<insert id="createDictConf">
insert into s2_dictionary
(`domain_id`, dim_value_infos, created_at, updated_at, created_by, updated_by)
values
(#{modelId}, #{dimValueInfos}, #{createdAt}, #{updatedAt}, #{createdBy}, #{updatedBy})
</insert>
<insert id="upsertDictInfo">
insert into s2_dictionary
(`model_id`, dim_value_infos, created_at, updated_at, created_by, updated_by)
values
(#{modelId}, #{dimValueInfos}, #{createdAt}, #{updatedAt}, #{createdBy}, #{updatedBy})
on duplicate key update
dim_value_infos = #{dimValueInfos},
updated_at = #{updatedAt},
updated_by = #{updatedBy}
</insert>
<update id="editDictConf">
update s2_dictionary
set dim_value_infos = #{dimValueInfos},
updated_at = #{updatedAt},
updated_by = #{updatedBy}
where model_id = #{modelId}
and status = 0
</update>
<select id="getDictInfoByModelId" resultMap="DictConfPO">
select *
from s2_dictionary
where model_id = #{modelId}
and status = 0
</select>
</mapper>

View File

@@ -0,0 +1,75 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.DictTaskMapper">
<resultMap id="DimValueDictTaskPO"
type="com.tencent.supersonic.chat.server.persistence.dataobject.DictTaskDO">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="description" property="description"/>
<result column="command" property="command"/>
<result column="command_md5" property="commandMd5"/>
<result column="dimension_ids" property="dimIds"/>
<result column="status" property="status"/>
<result column="created_by" property="createdBy"/>
<result column="created_at" property="createdAt"/>
<result column="progress" property="progress"/>
<result column="elapsed_ms" property="elapsedMs"/>
</resultMap>
<insert id="createDimValueTask" useGeneratedKeys="true" keyProperty="id">
insert into s2_dictionary_task
(`name`, description, command, command_md5, dimension_ids, status, created_by, progress, elapsed_ms)
values
(#{name}, #{description}, #{command}, #{commandMd5}, #{dimIds}, #{status}, #{createdBy}, #{progress}, #{elapsedMs})
</insert>
<update id="updateTaskStatus">
update s2_dictionary_task
<set>
<if test="description != null and description !=''">
description = #{description},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="dimIds != null">
dimension_ids = #{dimIds},
</if>
<if test="progress != null">
progress = #{progress},
</if>
<if test="elapsedMs != null">
elapsed_ms = #{elapsedMs},
</if>
</set>
where id = #{id}
</update>
<select id="searchDictTaskList" resultMap="DimValueDictTaskPO">
select *
from s2_dictionary_task
<where>
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name !=''">
and `name` like CONCAT('%', #{name}, '%')
</if>
<if test="createdBy != null and createdBy !=''">
and created_by = #{createdBy}
</if>
<if test="createdAt != null and createdAt !=''">
and created_at &gt;= #{createdAt}
</if>
<if test="status != null">
and status= #{status.code}
</if>
</where>
order by created_at desc
</select>
</mapper>

View File

@@ -0,0 +1,276 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.PluginDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="model" jdbcType="VARCHAR" property="model" />
<result column="pattern" jdbcType="VARCHAR" property="pattern" />
<result column="parse_mode" jdbcType="VARCHAR" property="parseMode" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
<result column="parse_mode_config" jdbcType="LONGVARCHAR" property="parseModeConfig" />
<result column="config" jdbcType="LONGVARCHAR" property="config" />
<result column="comment" jdbcType="LONGVARCHAR" property="comment" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, type, model, pattern, parse_mode, name, created_at, created_by, updated_at,
updated_by
</sql>
<sql id="Blob_Column_List">
parse_mode_config, config, comment
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_plugin
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_plugin
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limitStart != null and limitStart>=0">
limit #{limitStart} , #{limitEnd}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_plugin
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_plugin
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
insert into s2_plugin (id, type, model,
pattern, parse_mode, name,
created_at, created_by, updated_at,
updated_by, parse_mode_config, config,
comment)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{model,jdbcType=VARCHAR},
#{pattern,jdbcType=VARCHAR}, #{parseMode,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, #{updatedAt,jdbcType=TIMESTAMP},
#{updatedBy,jdbcType=VARCHAR}, #{parseModeConfig,jdbcType=LONGVARCHAR}, #{config,jdbcType=LONGVARCHAR},
#{comment,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
insert into s2_plugin
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="type != null">
type,
</if>
<if test="model != null">
model,
</if>
<if test="pattern != null">
pattern,
</if>
<if test="parseMode != null">
parse_mode,
</if>
<if test="name != null">
name,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="parseModeConfig != null">
parse_mode_config,
</if>
<if test="config != null">
config,
</if>
<if test="comment != null">
comment,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="model != null">
#{model,jdbcType=VARCHAR},
</if>
<if test="pattern != null">
#{pattern,jdbcType=VARCHAR},
</if>
<if test="parseMode != null">
#{parseMode,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="parseModeConfig != null">
#{parseModeConfig,jdbcType=LONGVARCHAR},
</if>
<if test="config != null">
#{config,jdbcType=LONGVARCHAR},
</if>
<if test="comment != null">
#{comment,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDOExample" resultType="java.lang.Long">
select count(*) from s2_plugin
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
update s2_plugin
<set>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
<if test="model != null">
model = #{model,jdbcType=VARCHAR},
</if>
<if test="pattern != null">
pattern = #{pattern,jdbcType=VARCHAR},
</if>
<if test="parseMode != null">
parse_mode = #{parseMode,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="parseModeConfig != null">
parse_mode_config = #{parseModeConfig,jdbcType=LONGVARCHAR},
</if>
<if test="config != null">
config = #{config,jdbcType=LONGVARCHAR},
</if>
<if test="comment != null">
comment = #{comment,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
update s2_plugin
set type = #{type,jdbcType=VARCHAR},
model = #{model,jdbcType=VARCHAR},
pattern = #{pattern,jdbcType=VARCHAR},
parse_mode = #{parseMode,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
parse_mode_config = #{parseModeConfig,jdbcType=LONGVARCHAR},
config = #{config,jdbcType=LONGVARCHAR},
comment = #{comment,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.PluginDO">
update s2_plugin
set type = #{type,jdbcType=VARCHAR},
model = #{model,jdbcType=VARCHAR},
pattern = #{pattern,jdbcType=VARCHAR},
parse_mode = #{parseMode,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -0,0 +1,35 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.StatisticsMapper">
<resultMap id="Statistics" type="com.tencent.supersonic.chat.server.persistence.dataobject.StatisticsDO">
<id column="question_id" property="questionId"/>
<result column="chat_id" property="chatId"/>
<result column="user_name" property="userName"/>
<result column="query_text" property="queryText"/>
<result column="interface_name" property="interfaceName"/>
<result column="cost" property="cost"/>
<result column="type" property="type"/>
<result column="create_time" property="createTime"/>
</resultMap>
<insert id="batchSaveStatistics" parameterType="com.tencent.supersonic.chat.server.persistence.dataobject.StatisticsDO">
insert into s2_chat_statistics
(question_id,chat_id, user_name, query_text, interface_name,cost,type ,create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.questionId}, #{item.chatId}, #{item.userName}, #{item.queryText}, #{item.interfaceName}, #{item.cost}, #{item.type},#{item.createTime})
</foreach>
</insert>
<select id="getStatistics" resultMap="Statistics">
select *
from s2_chat_statistics
where question_id = #{questionId} and user_name = #{userName}
limit 1
</select>
</mapper>

View File

@@ -0,0 +1,75 @@
<?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.tencent.supersonic.chat.server.persistence.mapper.custom.ShowCaseCustomMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO">
<id column="question_id" jdbcType="BIGINT" property="questionId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="user_name" jdbcType="VARCHAR" property="userName" />
<result column="query_state" jdbcType="INTEGER" property="queryState" />
<result column="chat_id" jdbcType="BIGINT" property="chatId" />
<result column="score" jdbcType="INTEGER" property="score" />
<result column="feedback" jdbcType="VARCHAR" property="feedback" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.chat.server.persistence.dataobject.ChatQueryDO">
<result column="query_text" jdbcType="LONGVARCHAR" property="queryText" />
<result column="query_result" jdbcType="LONGVARCHAR" property="queryResult" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and
#{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem"
open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, model_id, name, biz_name, description, type, created_at, created_by, updated_at, updated_by
</sql>
<sql id="Blob_Column_List">
typeParams
</sql>
<select id="queryShowCase" resultMap="ResultMapWithBLOBs">
select q1.*
from s2_chat_query q1
join (
select distinct chat_id
from (
select *
from s2_chat_query
where query_state = 1 and agent_id = ${agentId} and score = 5
<if test="userName != null and userName != ''">
and user_name = #{userName}
</if>
order by chat_id desc
) a
limit #{start}, #{limit}
) q2 on q1.chat_id = q2.chat_id
where agent_id = ${agentId} and score = 5
</select>
</mapper>