ChatDao.xml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.backendsys.modules.ai.chat.dao.ChatDao">
  4. <sql id="includeChat">
  5. id,
  6. history_code,
  7. model,
  8. model_version,
  9. role,
  10. COALESCE(content_type, '') content_type,
  11. content,
  12. COALESCE(duration, '') duration,
  13. user_id,
  14. COALESCE(robot_code, '') robot_code,
  15. del_flag,
  16. create_time,
  17. update_time
  18. </sql>
  19. <resultMap id="resultMapChat" type="com.backendsys.modules.ai.chat.entity.Chat">
  20. <id property="id" column="id" jdbcType="BIGINT" />
  21. <result property="history_code" column="history_code" />
  22. <result property="model" column="model" />
  23. <result property="model_version" column="model_version" />
  24. <result property="role" column="role" />
  25. <result property="content_type" column="content_type" />
  26. <result property="content" column="content" />
  27. <result property="duration" column="duration" javaType="java.lang.Long" />
  28. <result property="user_id" column="user_id" javaType="java.lang.Long" />
  29. <result property="robot_code" column="robot_code" />
  30. <result property="del_flag" column="del_flag" javaType="java.lang.Integer" />
  31. <result property="create_time" column="create_time" typeHandler="com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeHandler" />
  32. <result property="update_time" column="update_time" typeHandler="com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeHandler" />
  33. </resultMap>
  34. <!-- 查 列表 -->
  35. <select id="selectChatList" resultMap="resultMapChat">
  36. SELECT <include refid="includeChat" />
  37. FROM ai_chat
  38. <where>
  39. <if test="user_id != null and user_id != ''">
  40. AND user_id = #{user_id}
  41. </if>
  42. <if test="history_code != null and history_code != ''">
  43. AND history_code = #{history_code}
  44. </if>
  45. <if test="del_flag != null and del_flag != ''">
  46. AND del_flag = #{del_flag}
  47. </if>
  48. </where>
  49. ORDER BY create_time DESC, id DESC
  50. </select>
  51. </mapper>