first commit

This commit is contained in:
jerryjzhang
2023-06-12 18:44:01 +08:00
commit dc4fc69b57
879 changed files with 573090 additions and 0 deletions

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.infrastructure.mapper.ChatConfigMapper">
<resultMap id="chaConfigDO"
type="com.tencent.supersonic.chat.domain.dataobject.ChatConfigDO">
<id column="id" property="id"/>
<result column="domain_id" property="domainId"/>
<result column="default_metrics" property="defaultMetrics"/>
<result column="visibility" property="visibility"/>
<result column="entity_info" property="entity"/>
<result column="dictionary_info" property="knowledgeInfo"/>
<result column="status" property="status"/>
<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.domain.dataobject.ChatConfigDO"
useGeneratedKeys="true" keyProperty="id">
insert into s2_chat_config
(
domain_id, `default_metrics`, visibility, entity_info, dictionary_info, status, created_by, updated_by, created_at, updated_at
)
values
(
#{domainId}, #{defaultMetrics}, #{visibility}, #{entity}, #{knowledgeInfo}, #{status}, #{createdBy}, #{updatedBy}, #{createdAt}, #{updatedAt}
)
</insert>
<update id="editConfig">
update s2_chat_config
<set>
`updated_at` = #{updatedAt} ,
<if test="defaultMetrics != null and defaultMetrics != ''">
`default_metrics` = #{defaultMetrics} ,
</if>
<if test="visibility != null and visibility != ''">
visibility = #{visibility} ,
</if>
<if test="entity != null and entity != ''">
entity_info = #{entity} ,
</if>
<if test="knowledgeInfo != null and knowledgeInfo != ''">
`dictionary_info` = #{knowledgeInfo} ,
</if>
<if test="status != null and status != ''">
status = #{status} ,
</if>
<if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy} ,
</if>
</set>
<where>
<if test="id != null and id != ''">
id = #{id}
</if>
<if test="domainId != null and domainId != ''">
and domain_id = #{domainId}
</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="domainId != null and domainId != ''">
and domain_id = #{domainId}
</if>
<if test="status != null and status != ''">
and status = #{status}
</if>
</where>
</select>
<select id="fetchConfigByDomainId" resultMap="chaConfigDO">
select *
from s2_chat_config
where domain_id = #{domainId}
order by status
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.infrastructure.mapper.ChatContextMapper">
<resultMap id="ChatContextDO"
type="com.tencent.supersonic.chat.domain.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.domain.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,107 @@
<?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.infrastructure.mapper.ChatMapper">
<resultMap id="IntelligentConversion" type="com.tencent.supersonic.chat.domain.dataobject.ChatDO">
<id column="chat_id" property="chatId"/>
<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
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>
<insert id="createChat" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatDO">
insert into s2_chat
(chat_name, create_time, last_time, creator, last_question, is_delete, is_top)
values (#{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.domain.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.domain.dataobject.QueryDO">
update s2_chat_query
set score=#{score},
feedback=#{feedback}
where id = #{id}
</update>
<insert id="createQuery" parameterType="com.tencent.supersonic.chat.domain.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,67 @@
package com.tencent.supersonic.domain.chat.infrastructure.persistence.mybatis.mapper;
import com.tencent.supersonic.chat.domain.dataobject.ChatQueryDO;
import com.tencent.supersonic.chat.domain.dataobject.ChatQueryDOExample;
import java.util.List;
public interface ChatQueryDOMapper {
/**
*
* @mbg.generated
*/
long countByExample(ChatQueryDOExample example);
/**
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
*
* @mbg.generated
*/
int insert(ChatQueryDO record);
/**
*
* @mbg.generated
*/
int insertSelective(ChatQueryDO record);
/**
*
* @mbg.generated
*/
List<ChatQueryDO> selectByExampleWithBLOBs(ChatQueryDOExample example);
/**
*
* @mbg.generated
*/
List<ChatQueryDO> selectByExample(ChatQueryDOExample example);
/**
*
* @mbg.generated
*/
ChatQueryDO selectByPrimaryKey(Long id);
/**
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(ChatQueryDO record);
/**
*
* @mbg.generated
*/
int updateByPrimaryKeyWithBLOBs(ChatQueryDO record);
/**
*
* @mbg.generated
*/
int updateByPrimaryKey(ChatQueryDO record);
}

View File

@@ -0,0 +1,226 @@
<?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.infrastructure.mapper.ChatQueryDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.chat.domain.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.domain.dataobject.ChatQueryDO">
<result column="query_text" jdbcType="LONGVARCHAR" property="queryText" />
<result column="query_response" jdbcType="LONGVARCHAR" property="queryResponse" />
</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, create_time, user_name, query_state, chat_id, score, feedback
</sql>
<sql id="Blob_Column_List">
query_text, query_response
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.chat.domain.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="selectByExample" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatQueryDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_chat_query
<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_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.domain.dataobject.ChatQueryDO">
insert into s2_chat_query (question_id, create_time, user_name,
query_state, chat_id, score,
feedback, query_text, query_response
)
values (#{questionId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{userName,jdbcType=VARCHAR},
#{queryState,jdbcType=INTEGER}, #{chatId,jdbcType=BIGINT}, #{score,jdbcType=INTEGER},
#{feedback,jdbcType=VARCHAR}, #{queryText,jdbcType=LONGVARCHAR}, #{queryResponse,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatQueryDO">
insert into s2_chat_query
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="questionId != null">
question_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="userName != null">
user_name,
</if>
<if test="queryState != null">
query_state,
</if>
<if test="chatId != null">
chat_id,
</if>
<if test="score != null">
score,
</if>
<if test="feedback != null">
feedback,
</if>
<if test="queryText != null">
query_text,
</if>
<if test="queryResponse != null">
query_response,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="questionId != null">
#{questionId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="userName != null">
#{userName,jdbcType=VARCHAR},
</if>
<if test="queryState != null">
#{queryState,jdbcType=INTEGER},
</if>
<if test="chatId != null">
#{chatId,jdbcType=BIGINT},
</if>
<if test="score != null">
#{score,jdbcType=INTEGER},
</if>
<if test="feedback != null">
#{feedback,jdbcType=VARCHAR},
</if>
<if test="queryText != null">
#{queryText,jdbcType=LONGVARCHAR},
</if>
<if test="queryResponse != null">
#{queryResponse,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatQueryDOExample" resultType="java.lang.Long">
select count(*) from s2_chat_query
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.chat.domain.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="queryResponse != null">
query_response = #{queryResponse,jdbcType=LONGVARCHAR},
</if>
</set>
where question_id = #{questionId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatQueryDO">
update s2_chat_query
set create_time = #{createTime,jdbcType=TIMESTAMP},
user_name = #{userName,jdbcType=VARCHAR},
query_state = #{queryState,jdbcType=INTEGER},
chat_id = #{chatId,jdbcType=BIGINT},
score = #{score,jdbcType=INTEGER},
feedback = #{feedback,jdbcType=VARCHAR},
query_text = #{queryText,jdbcType=LONGVARCHAR},
query_response = #{queryResponse,jdbcType=LONGVARCHAR}
where question_id = #{questionId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.chat.domain.dataobject.ChatQueryDO">
update s2_chat_query
set create_time = #{createTime,jdbcType=TIMESTAMP},
user_name = #{userName,jdbcType=VARCHAR},
query_state = #{queryState,jdbcType=INTEGER},
chat_id = #{chatId,jdbcType=BIGINT},
score = #{score,jdbcType=INTEGER},
feedback = #{feedback,jdbcType=VARCHAR}
where question_id = #{questionId,jdbcType=BIGINT}
</update>
</mapper>