CcLlmKbMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.aicall.mapper.CcLlmKbMapper">
  6. <resultMap type="CcLlmKb" id="CcLlmKbResult">
  7. <result property="id" column="id" />
  8. <result property="title" column="title" />
  9. <result property="content" column="content" />
  10. <result property="catId" column="cat_id" />
  11. </resultMap>
  12. <sql id="selectCcLlmKbVo">
  13. select id, title, content, cat_id from cc_llm_kb
  14. </sql>
  15. <select id="selectCcLlmKbList" parameterType="CcLlmKb" resultMap="CcLlmKbResult">
  16. <include refid="selectCcLlmKbVo"/>
  17. <where>
  18. <if test="title != null and title != ''"> and title = #{title}</if>
  19. <if test="content != null and content != ''"> and content = #{content}</if>
  20. <if test="catId != null "> and cat_id = #{catId}</if>
  21. </where>
  22. </select>
  23. <select id="selectCcLlmKbById" parameterType="Long" resultMap="CcLlmKbResult">
  24. <include refid="selectCcLlmKbVo"/>
  25. where id = #{id}
  26. </select>
  27. <insert id="insertCcLlmKb" parameterType="CcLlmKb">
  28. insert into cc_llm_kb
  29. <trim prefix="(" suffix=")" suffixOverrides=",">
  30. <if test="id != null">id,</if>
  31. <if test="title != null and title != ''">title,</if>
  32. <if test="content != null and content != ''">content,</if>
  33. <if test="catId != null">cat_id,</if>
  34. </trim>
  35. <trim prefix="values (" suffix=")" suffixOverrides=",">
  36. <if test="id != null">#{id},</if>
  37. <if test="title != null and title != ''">#{title},</if>
  38. <if test="content != null and content != ''">#{content},</if>
  39. <if test="catId != null">#{catId},</if>
  40. </trim>
  41. </insert>
  42. <update id="updateCcLlmKb" parameterType="CcLlmKb">
  43. update cc_llm_kb
  44. <trim prefix="SET" suffixOverrides=",">
  45. <if test="title != null and title != ''">title = #{title},</if>
  46. <if test="content != null and content != ''">content = #{content},</if>
  47. <if test="catId != null">cat_id = #{catId},</if>
  48. </trim>
  49. where id = #{id}
  50. </update>
  51. <delete id="deleteCcLlmKbById" parameterType="Long">
  52. delete from cc_llm_kb where id = #{id}
  53. </delete>
  54. <delete id="deleteCcLlmKbByIds" parameterType="String">
  55. delete from cc_llm_kb where id in
  56. <foreach item="id" collection="array" open="(" separator="," close=")">
  57. #{id}
  58. </foreach>
  59. </delete>
  60. <select id="selectCountByCatId" parameterType="Long">
  61. select count(1) from cc_llm_kb where cat_id = #{catId}
  62. </select>
  63. <delete id="deleteCcLlmKbByCatId" parameterType="Long">
  64. delete from cc_llm_kb where cat_id = #{catId}
  65. </delete>
  66. <!-- 批量插入 -->
  67. <insert id="insertBatch" parameterType="java.util.List">
  68. INSERT INTO cc_llm_kb
  69. (title, content, cat_id)
  70. VALUES
  71. <foreach collection="list" item="e" separator=",">
  72. (#{e.title},
  73. #{e.content},
  74. #{e.catId})
  75. </foreach>
  76. </insert>
  77. </mapper>