AdminAiSceneModelMapper.xml 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.fs.company.mapper.AdminAiSceneModelMapper">
  4. <resultMap type="com.fs.company.domain.AdminAiSceneModel" id="AdminAiSceneModelResult">
  5. <id property="id" column="id"/>
  6. <result property="sceneCode" column="scene_code"/>
  7. <result property="modelId" column="model_id"/>
  8. <result property="pipelineOrder" column="pipeline_order"/>
  9. <result property="role" column="role"/>
  10. <result property="sortWeight" column="sort_weight"/>
  11. <result property="createTime" column="create_time"/>
  12. </resultMap>
  13. <resultMap type="com.fs.company.domain.AdminAiSceneModel" id="AdminAiSceneModelWithModelResult" extends="AdminAiSceneModelResult">
  14. <association property="model" javaType="com.fs.company.domain.AdminAiModel">
  15. <id property="id" column="m_id"/>
  16. <result property="modelName" column="m_model_name"/>
  17. <result property="providerCode" column="m_provider_code"/>
  18. <result property="modelIdentifier" column="m_model_identifier"/>
  19. <result property="apiEndpoint" column="m_api_endpoint"/>
  20. <result property="apiKey" column="m_api_key"/>
  21. <result property="embeddingEndpoint" column="m_embedding_endpoint"/>
  22. <result property="maxTokens" column="m_max_tokens"/>
  23. <result property="temperature" column="m_temperature"/>
  24. <result property="sortOrder" column="m_sort_order"/>
  25. <result property="status" column="m_status"/>
  26. </association>
  27. </resultMap>
  28. <select id="selectBySceneCode" resultMap="AdminAiSceneModelWithModelResult">
  29. select sm.id, sm.scene_code, sm.model_id, sm.pipeline_order, sm.role, sm.sort_weight, sm.create_time,
  30. m.id as m_id, m.model_name as m_model_name, m.provider_code as m_provider_code,
  31. m.model_identifier as m_model_identifier, m.api_endpoint as m_api_endpoint,
  32. m.api_key as m_api_key, m.embedding_endpoint as m_embedding_endpoint,
  33. m.max_tokens as m_max_tokens, m.temperature as m_temperature,
  34. m.sort_order as m_sort_order, m.status as m_status
  35. from admin_ai_scene_model sm
  36. inner join admin_ai_model m on sm.model_id = m.id
  37. where sm.scene_code = #{sceneCode}
  38. order by sm.pipeline_order asc, sm.sort_weight asc
  39. </select>
  40. <select id="selectEnabledBySceneCode" resultMap="AdminAiSceneModelWithModelResult">
  41. select sm.id, sm.scene_code, sm.model_id, sm.pipeline_order, sm.role, sm.sort_weight, sm.create_time,
  42. m.id as m_id, m.model_name as m_model_name, m.provider_code as m_provider_code,
  43. m.model_identifier as m_model_identifier, m.api_endpoint as m_api_endpoint,
  44. m.api_key as m_api_key, m.embedding_endpoint as m_embedding_endpoint,
  45. m.max_tokens as m_max_tokens, m.temperature as m_temperature,
  46. m.sort_order as m_sort_order, m.status as m_status
  47. from admin_ai_scene_model sm
  48. inner join admin_ai_model m on sm.model_id = m.id
  49. where sm.scene_code = #{sceneCode} and m.status = 1
  50. order by sm.pipeline_order asc, sm.sort_weight asc
  51. </select>
  52. <select id="selectAll" resultMap="AdminAiSceneModelWithModelResult">
  53. select sm.id, sm.scene_code, sm.model_id, sm.pipeline_order, sm.role, sm.sort_weight, sm.create_time,
  54. m.id as m_id, m.model_name as m_model_name, m.provider_code as m_provider_code,
  55. m.model_identifier as m_model_identifier, m.api_endpoint as m_api_endpoint,
  56. m.api_key as m_api_key, m.embedding_endpoint as m_embedding_endpoint,
  57. m.max_tokens as m_max_tokens, m.temperature as m_temperature,
  58. m.sort_order as m_sort_order, m.status as m_status
  59. from admin_ai_scene_model sm
  60. inner join admin_ai_model m on sm.model_id = m.id
  61. order by sm.scene_code, sm.pipeline_order asc, sm.sort_weight asc
  62. </select>
  63. <insert id="insert" useGeneratedKeys="true" keyProperty="id">
  64. insert into admin_ai_scene_model (
  65. scene_code, model_id, pipeline_order, role, sort_weight, create_time
  66. ) values (
  67. #{sceneCode}, #{modelId}, #{pipelineOrder}, #{role}, #{sortWeight}, NOW()
  68. )
  69. </insert>
  70. <delete id="deleteById">
  71. delete from admin_ai_scene_model where id = #{id}
  72. </delete>
  73. <delete id="deleteBySceneCode">
  74. delete from admin_ai_scene_model where scene_code = #{sceneCode}
  75. </delete>
  76. <delete id="deleteBySceneAndModel">
  77. delete from admin_ai_scene_model where scene_code = #{sceneCode} and model_id = #{modelId}
  78. </delete>
  79. <update id="updateOrder">
  80. update admin_ai_scene_model
  81. set pipeline_order = #{pipelineOrder}, role = #{role}, sort_weight = #{sortWeight}
  82. where id = #{id}
  83. </update>
  84. </mapper>