CtShortVideoMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.delivery.mapper.CtShortVideoMapper">
  6. <resultMap type="CtShortVideo" id="CtShortVideoResult">
  7. <result property="id" column="id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyName" column="companyName"/>
  10. <result property="title" column="title" />
  11. <result property="groupId" column="group_id" />
  12. <result property="tags" column="tags" />
  13. <result property="taskType" column="task_type" />
  14. <result property="authorTypeId" column="author_type_id" />
  15. <result property="authorId" column="author_id" />
  16. <result property="authorName" column="authorName"/>
  17. <result property="isOriginal" column="is_original" />
  18. <result property="coverUrl" column="cover_url" />
  19. <result property="summary" column="summary" />
  20. <result property="videoUrl" column="video_url" />
  21. <result property="status" column="status" />
  22. <result property="createBy" column="create_by" />
  23. <result property="createTime" column="create_time" />
  24. <result property="updateBy" column="update_by" />
  25. <result property="updateTime" column="update_time" />
  26. <result property="delFlag" column="del_flag" />
  27. </resultMap>
  28. <sql id="selectCtShortVideoVo">
  29. SELECT
  30. v.id,
  31. v.company_id,
  32. c.company_name AS companyName,
  33. v.title,
  34. v.group_id,
  35. v.tags,
  36. v.task_type,
  37. v.author_type_id,
  38. v.author_id,
  39. -- ✅ 关键:关联讲者表拿到姓名(用于前端回显)
  40. d.doctor_name AS authorName,
  41. v.is_original,
  42. v.cover_url,
  43. v.summary,
  44. v.video_url,
  45. v.status,
  46. v.create_by,
  47. v.create_time,
  48. v.update_by,
  49. v.update_time,
  50. v.del_flag
  51. FROM ct_short_video v
  52. LEFT JOIN company c ON c.company_id = v.company_id
  53. -- ✅ author_id 对应 doctor.id(你给的 doctor 表主键就是 id)
  54. -- ✅ 同时加 company_id 约束更安全(避免跨公司串数据)
  55. LEFT JOIN doctor d ON d.id = v.author_id AND d.company_id = v.company_id
  56. </sql>
  57. <select id="selectCtShortVideoList" parameterType="CtShortVideo" resultMap="CtShortVideoResult">
  58. <include refid="selectCtShortVideoVo"/>
  59. <where>
  60. <if test="companyId != null"> and v.company_id = #{companyId}</if>
  61. <if test="title != null and title != ''"> and v.title = #{title}</if>
  62. <if test="groupId != null"> and v.group_id = #{groupId}</if>
  63. <if test="tags != null and tags != ''"> and v.tags = #{tags}</if>
  64. <if test="taskType != null"> and v.task_type = #{taskType}</if>
  65. <if test="authorTypeId != null"> and v.author_type_id = #{authorTypeId}</if>
  66. <if test="authorId != null"> and v.author_id = #{authorId}</if>
  67. <if test="isOriginal != null"> and v.is_original = #{isOriginal}</if>
  68. <if test="coverUrl != null and coverUrl != ''"> and v.cover_url = #{coverUrl}</if>
  69. <if test="summary != null and summary != ''"> and v.summary = #{summary}</if>
  70. <if test="videoUrl != null and videoUrl != ''"> and v.video_url = #{videoUrl}</if>
  71. <if test="status != null"> and v.status = #{status}</if>
  72. </where>
  73. order by v.create_time desc
  74. </select>
  75. <select id="selectCtShortVideoById" parameterType="Long" resultMap="CtShortVideoResult">
  76. <include refid="selectCtShortVideoVo"/>
  77. where v.id = #{id}
  78. </select>
  79. <insert id="insertCtShortVideo" parameterType="CtShortVideo" useGeneratedKeys="true" keyProperty="id">
  80. insert into ct_short_video
  81. <trim prefix="(" suffix=")" suffixOverrides=",">
  82. <if test="title != null and title != ''">title,</if>
  83. <if test="groupId != null">group_id,</if>
  84. <if test="tags != null">tags,</if>
  85. <if test="taskType != null">task_type,</if>
  86. <if test="authorTypeId != null">author_type_id,</if>
  87. <if test="authorId != null">author_id,</if>
  88. <if test="isOriginal != null">is_original,</if>
  89. <if test="coverUrl != null">cover_url,</if>
  90. <if test="summary != null">summary,</if>
  91. <if test="videoUrl != null">video_url,</if>
  92. <if test="status != null">status,</if>
  93. <if test="createBy != null">create_by,</if>
  94. <if test="createTime != null">create_time,</if>
  95. <if test="updateBy != null">update_by,</if>
  96. <if test="updateTime != null">update_time,</if>
  97. <if test="delFlag != null">del_flag,</if>
  98. <if test="companyId != null">company_id,</if>
  99. </trim>
  100. <trim prefix="values (" suffix=")" suffixOverrides=",">
  101. <if test="title != null and title != ''">#{title},</if>
  102. <if test="groupId != null">#{groupId},</if>
  103. <if test="tags != null">#{tags},</if>
  104. <if test="taskType != null">#{taskType},</if>
  105. <if test="authorTypeId != null">#{authorTypeId},</if>
  106. <if test="authorId != null">#{authorId},</if>
  107. <if test="isOriginal != null">#{isOriginal},</if>
  108. <if test="coverUrl != null">#{coverUrl},</if>
  109. <if test="summary != null">#{summary},</if>
  110. <if test="videoUrl != null">#{videoUrl},</if>
  111. <if test="status != null">#{status},</if>
  112. <if test="createBy != null">#{createBy},</if>
  113. <if test="createTime != null">#{createTime},</if>
  114. <if test="updateBy != null">#{updateBy},</if>
  115. <if test="updateTime != null">#{updateTime},</if>
  116. <if test="delFlag != null">#{delFlag},</if>
  117. <if test="companyId != null">#{companyId},</if>
  118. </trim>
  119. </insert>
  120. <update id="updateCtShortVideo" parameterType="CtShortVideo">
  121. update ct_short_video
  122. <trim prefix="SET" suffixOverrides=",">
  123. <if test="title != null and title != ''">title = #{title},</if>
  124. <if test="groupId != null">group_id = #{groupId},</if>
  125. <if test="tags != null">tags = #{tags},</if>
  126. <if test="taskType != null">task_type = #{taskType},</if>
  127. <if test="authorTypeId != null">author_type_id = #{authorTypeId},</if>
  128. <if test="authorId != null">author_id = #{authorId},</if>
  129. <if test="isOriginal != null">is_original = #{isOriginal},</if>
  130. <if test="coverUrl != null">cover_url = #{coverUrl},</if>
  131. <if test="summary != null">summary = #{summary},</if>
  132. <if test="videoUrl != null">video_url = #{videoUrl},</if>
  133. <if test="status != null">status = #{status},</if>
  134. <if test="createBy != null">create_by = #{createBy},</if>
  135. <if test="createTime != null">create_time = #{createTime},</if>
  136. <if test="updateBy != null">update_by = #{updateBy},</if>
  137. <if test="updateTime != null">update_time = #{updateTime},</if>
  138. <if test="delFlag != null">del_flag = #{delFlag},</if>
  139. <if test="companyId != null">company_id = #{companyId},</if>
  140. </trim>
  141. where id = #{id}
  142. </update>
  143. <delete id="deleteCtShortVideoById" parameterType="Long">
  144. delete from ct_short_video where id = #{id}
  145. </delete>
  146. <delete id="deleteCtShortVideoByIds" parameterType="String">
  147. delete from ct_short_video where id in
  148. <foreach item="id" collection="array" open="(" separator="," close=")">
  149. #{id}
  150. </foreach>
  151. </delete>
  152. </mapper>