| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?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.takai.ai.mapper.TakaiDialogMapper">
-
- <resultMap type="com.takai.ai.domain.dto.TakaiDialogRespDTO" id="TakaiDialogResult">
- <id property="id" column="id" />
- <result property="dialog_name" column="dialog_name" />
- <result property="dialog_id" column="dialog_id" />
- <result property="did" column="did" />
- <result property="content" column="content" />
- <result property="type" column="type" />
- <result property="create_time" column="create_time" />
- </resultMap>
- <select id="selectDialogById" parameterType="String" resultMap="TakaiDialogResult">
- select id
- from dialog
- <where>
- <if test="dialogId != null and dialogId != ''">
- AND id = #{dialogId}
- </if>
- </where>
- </select>
- <select id="selectDialogDetailById" parameterType="String" resultMap="TakaiDialogResult">
- select id
- from dialog_detail
- <where>
- <if test="detailId != null and detailId != ''">
- AND id = #{detailId}
- </if>
- </where>
- </select>
- <select id="selectDialogList" resultMap="TakaiDialogResult">
- select
- d.id as id,
- d.app_id as appId,
- d.dialog_name as dialog_name,
- date_format(d.create_time, '%Y-%m-%d') as create_time
- from dialog d
- <where>
- <if test="appId != null">
- d.app_id = #{appId}
- </if>
- </where>
- GROUP BY d.id,d.app_id,d.dialog_name,d.create_time
- ORDER BY d.create_time desc
- </select>
- <insert id="insertDialog" parameterType="DialogReqDTO">
- insert into dialog(
- id,
- <if test="appId != null">app_id,</if>
- <if test="knowledgeId != null">knowledge_id,</if>
- <if test="userId != null">user_id,</if>
- <if test="dialogName != null">dialog_name,</if>
- create_time
- )values(
- #{id},
- <if test="appId != null">#{appId},</if>
- <if test="knowledgeId != null">#{knowledgeId},</if>
- <if test="userId != null">#{userId},</if>
- <if test="dialogName != null">#{dialogName},</if>
- sysdate()
- )
- </insert>
- <insert id="insertDialogDetail" parameterType="DialogDetailReqDTO">
- insert into dialog_detail(
- id,
- <if test="dialogId != null">dialog_id,</if>
- <if test="role != null">type,</if>
- <if test="content != null">content,</if>
- <if test="role != null">create_by,</if>
- create_time
- )values(
- #{id},
- <if test="dialogId != null">#{dialogId},</if>
- <if test="role != null">#{role},</if>
- <if test="content != null">#{content},</if>
- <if test="role != null">#{role},</if>
- sysdate()
- )
- </insert>
- <select id="selectDialogDetail" resultMap="TakaiDialogResult">
- select
- d.id,
- d.app_id as appId,
- d.knowledge_id as knowledgeId,
- d.user_id as userId,
- d.dialog_name,
- d.create_time,
- dd.id as did,
- dd.type,
- dd.content,
- dd.dialog_id
- from dialog d
- left join dialog_detail dd on d.id = dd.dialog_id
- where dd.dialog_id = #{dialogId}
- ORDER BY dd.create_time asc, dd.type desc
- </select>
- <delete id="delDialog" parameterType="String">
- delete from dialog where id = #{id}
- </delete>
- <delete id="delDialogDetail" parameterType="String">
- delete from dialog_detail where dialog_id = #{dialogId}
- </delete>
- <update id="updateDialog" parameterType="DialogDetailReqDTO">
- update dialog set dialog_name = #{dialogName} where id = #{id}
- </update>
- <select id="selectDialogExport" resultMap="TakaiDialogResult">
- select
- d.id,
- d.app_id as appId,
- d.knowledge_id as knowledgeId,
- d.user_id as userId,
- d.dialog_name,
- d.create_time,
- dd.id as did,
- dd.type,
- dd.content,
- dd.dialog_id
- from dialog d
- left join dialog_detail dd on d.id = dd.dialog_id
- where dd.dialog_id = #{id}
- ORDER BY dd.create_time asc, dd.type desc
- </select>
- <select id="selectDialogListByAppId" resultMap="TakaiDialogResult">
- select
- d.id,
- d.app_id as appId,
- d.knowledge_id as knowledgeId,
- d.user_id as userId,
- d.dialog_name,
- d.create_time,
- dd.id as did,
- dd.type,
- dd.content,
- dd.dialog_id
- from dialog d
- left join dialog_detail dd on d.id = dd.dialog_id
- <where>
- <if test="appId != null">
- d.app_id = #{appId}
- </if>
- </where>
- ORDER BY dd.create_time asc, dd.type desc
- </select>
- <select id="selectDialog" resultMap="TakaiDialogResult">
- select
- d.id,
- d.app_id as appId,
- d.knowledge_id as knowledgeId,
- d.user_id as userId,
- d.dialog_name,
- d.create_time
- from dialog d
- <where>
- <if test="appId != null and appId != null">
- d.app_id = #{appId}
- </if>
- <if test="userId != null and userId != null">
- d.user_id = #{userId}
- </if>
- </where>
- ORDER BY d.create_time asc
- </select>
- </mapper>
|