FsUserCourseVideoMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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.course.mapper.FsUserCourseVideoMapper">
  6. <resultMap type="FsUserCourseVideo" id="FsUserCourseVideoResult">
  7. <result property="videoId" column="video_id" />
  8. <result property="fileId" column="file_id" />
  9. <result property="title" column="title" />
  10. <result property="description" column="description" />
  11. <result property="videoUrl" column="video_url" />
  12. <result property="thumbnail" column="thumbnail" />
  13. <result property="duration" column="duration" />
  14. <result property="updateTime" column="update_time" />
  15. <result property="createTime" column="create_time" />
  16. <result property="talentId" column="talent_id" />
  17. <result property="courseId" column="course_id" />
  18. <result property="status" column="status" />
  19. <result property="courseSort" column="course_sort" />
  20. <result property="fileName" column="file_name" />
  21. <result property="isDel" column="is_del" />
  22. <result property="questionBankId" column="question_bank_id" />
  23. <result property="lineOne" column="line_one" />
  24. <result property="lineTwo" column="line_two" />
  25. <result property="lineThree" column="line_three" />
  26. <result property="uploadType" column="upload_type" />
  27. <result property="redPacketMoney" column="red_packet_money" />
  28. <result property="fileSize" column="file_size" />
  29. <result property="fileKey" column="file_key" />
  30. <result property="round" column="round" />
  31. <result property="packageJson" column="package_json" />
  32. <result property="isTranscode" column="is_transcode" />
  33. <result property="transcodeFileKey" column="transcode_file_key" />
  34. <result property="viewStartTime" column="view_start_time" />
  35. <result property="viewEndTime" column="view_end_time" />
  36. <result property="lastJoinTime" column="last_join_time" />
  37. </resultMap>
  38. <sql id="selectFsUserCourseVideoVo">
  39. select * from fs_user_course_video
  40. </sql>
  41. <select id="selectFsUserCourseVideoList" parameterType="FsUserCourseVideo" resultMap="FsUserCourseVideoResult">
  42. <include refid="selectFsUserCourseVideoVo"/>
  43. <where>
  44. <if test="fileId != null and fileId != ''"> and file_id = #{fileId}</if>
  45. <if test="title != null and title != ''"> and title = #{title}</if>
  46. <if test="description != null and description != ''"> and description = #{description}</if>
  47. <if test="videoUrl != null and videoUrl != ''"> and video_url = #{videoUrl}</if>
  48. <if test="thumbnail != null and thumbnail != ''"> and thumbnail = #{thumbnail}</if>
  49. <if test="duration != null "> and duration = #{duration}</if>
  50. <if test="talentId != null "> and talent_id = #{talentId}</if>
  51. <if test="courseId != null "> and course_id = #{courseId}</if>
  52. <if test="status != null "> and status = #{status}</if>
  53. <if test="courseSort != null "> and course_sort = #{courseSort}</if>
  54. <if test="questionBankId != null "> and question_bank_id = #{questionBankId}</if>
  55. <if test="userId != null "> and user_id = #{userId}</if>
  56. </where>
  57. </select>
  58. <select id="selectFsUserCourseVideoByVideoId" parameterType="Long" resultMap="FsUserCourseVideoResult">
  59. <include refid="selectFsUserCourseVideoVo"/>
  60. where video_id = #{videoId}
  61. </select>
  62. <insert id="insertFsUserCourseVideo" parameterType="FsUserCourseVideo" useGeneratedKeys="true" keyProperty="videoId">
  63. insert into fs_user_course_video
  64. <trim prefix="(" suffix=")" suffixOverrides=",">
  65. <if test="fileId != null">file_id,</if>
  66. <if test="title != null">title,</if>
  67. <if test="description != null">description,</if>
  68. <if test="videoUrl != null">video_url,</if>
  69. <if test="thumbnail != null">thumbnail,</if>
  70. <if test="duration != null">duration,</if>
  71. <if test="updateTime != null">update_time,</if>
  72. <if test="createTime != null">create_time,</if>
  73. <if test="talentId != null">talent_id,</if>
  74. <if test="courseId != null">course_id,</if>
  75. <if test="status != null">status,</if>
  76. <if test="courseSort != null">course_sort,</if>
  77. <if test="fileName != null">file_name,</if>
  78. <if test="isDel != null">is_del,</if>
  79. <if test="questionBankId != null">question_bank_id,</if>
  80. <if test="lineOne != null">line_one,</if>
  81. <if test="lineTwo != null">line_two,</if>
  82. <if test="lineThree != null">line_three,</if>
  83. <if test="uploadType != null">upload_type,</if>
  84. <if test="redPacketMoney != null">red_packet_money,</if>
  85. <if test="fileSize != null">file_size,</if>
  86. <if test="fileKey != null">file_key,</if>
  87. <if test="round != null">round,</if>
  88. <if test="packageJson != null">package_json,</if>
  89. <if test="isTranscode != null">is_transcode,</if>
  90. <if test="transcodeFileKey != null">transcode_file_key,</if>
  91. <if test="viewStartTime != null">view_start_time,</if>
  92. <if test="viewEndTime != null">view_end_time,</if>
  93. <if test="lastJoinTime != null">last_join_time,</if>
  94. <if test="userId != null">user_id,</if>
  95. </trim>
  96. <trim prefix="values (" suffix=")" suffixOverrides=",">
  97. <if test="fileId != null">#{fileId},</if>
  98. <if test="title != null">#{title},</if>
  99. <if test="description != null">#{description},</if>
  100. <if test="videoUrl != null">#{videoUrl},</if>
  101. <if test="thumbnail != null">#{thumbnail},</if>
  102. <if test="duration != null">#{duration},</if>
  103. <if test="updateTime != null">#{updateTime},</if>
  104. <if test="createTime != null">#{createTime},</if>
  105. <if test="talentId != null">#{talentId},</if>
  106. <if test="courseId != null">#{courseId},</if>
  107. <if test="status != null">#{status},</if>
  108. <if test="courseSort != null">#{courseSort},</if>
  109. <if test="fileName != null">#{fileName},</if>
  110. <if test="isDel != null">#{isDel},</if>
  111. <if test="questionBankId != null">#{questionBankId},</if>
  112. <if test="lineOne != null">#{lineOne},</if>
  113. <if test="lineTwo != null">#{lineTwo},</if>
  114. <if test="lineThree != null">#{lineThree},</if>
  115. <if test="uploadType != null">#{uploadType},</if>
  116. <if test="redPacketMoney != null">#{redPacketMoney},</if>
  117. <if test="fileSize != null">#{fileSize},</if>
  118. <if test="fileKey != null">#{fileKey},</if>
  119. <if test="round != null">#{round},</if>
  120. <if test="packageJson != null">#{packageJson},</if>
  121. <if test="isTranscode != null">#{isTranscode},</if>
  122. <if test="transcodeFileKey != null">#{transcodeFileKey},</if>
  123. <if test="viewStartTime != null">#{viewStartTime},</if>
  124. <if test="viewEndTime != null">#{viewEndTime},</if>
  125. <if test="lastJoinTime != null">#{lastJoinTime},</if>
  126. <if test="userId != null">#{userId},</if>
  127. </trim>
  128. </insert>
  129. <insert id="insertBatchFsUserCourseVideo" parameterType="FsUserCourseVideo" useGeneratedKeys="true" keyProperty="videoId">
  130. insert into fs_user_course_video
  131. (
  132. title,
  133. video_url,
  134. thumbnail,
  135. duration,
  136. course_id,
  137. status,
  138. course_sort,
  139. file_name,
  140. question_bank_id,
  141. line_one,
  142. line_two,
  143. line_three,
  144. red_packet_money,
  145. file_size,
  146. file_key,
  147. is_transcode,
  148. user_id
  149. )
  150. values
  151. <foreach collection="collect" item="item" separator=",">
  152. (
  153. #{item.title},
  154. #{item.videoUrl},
  155. #{item.thumbnail},
  156. #{item.duration},
  157. #{item.courseId},
  158. #{item.status},
  159. #{item.courseSort},
  160. #{item.fileName},
  161. #{item.questionBankId},
  162. #{item.lineOne},
  163. #{item.lineTwo},
  164. #{item.lineThree},
  165. #{item.redPacketMoney},
  166. #{item.fileSize},
  167. #{item.fileKey},
  168. #{item.isTranscode},
  169. #{item.userId}
  170. )
  171. </foreach>
  172. </insert>
  173. <update id="updateFsUserCourseVideo" parameterType="FsUserCourseVideo">
  174. update fs_user_course_video
  175. <trim prefix="SET" suffixOverrides=",">
  176. <if test="fileId != null">file_id = #{fileId},</if>
  177. <if test="title != null">title = #{title},</if>
  178. <if test="description != null">description = #{description},</if>
  179. <if test="videoUrl != null">video_url = #{videoUrl},</if>
  180. <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
  181. <if test="duration != null">duration = #{duration},</if>
  182. <if test="updateTime != null">update_time = #{updateTime},</if>
  183. <if test="createTime != null">create_time = #{createTime},</if>
  184. <if test="talentId != null">talent_id = #{talentId},</if>
  185. <if test="courseId != null">course_id = #{courseId},</if>
  186. <if test="status != null">status = #{status},</if>
  187. <if test="courseSort != null">course_sort = #{courseSort},</if>
  188. <if test="fileName != null">file_name = #{fileName},</if>
  189. <if test="isDel != null">is_del = #{isDel},</if>
  190. <if test="questionBankId != null">question_bank_id = #{questionBankId},</if>
  191. <if test="lineOne != null">line_one = #{lineOne},</if>
  192. <if test="lineTwo != null">line_two = #{lineTwo},</if>
  193. <if test="lineThree != null">line_three = #{lineThree},</if>
  194. <if test="uploadType != null">upload_type = #{uploadType},</if>
  195. <if test="redPacketMoney != null">red_packet_money = #{redPacketMoney},</if>
  196. <if test="fileSize != null">file_size = #{fileSize},</if>
  197. <if test="fileKey != null">file_key = #{fileKey},</if>
  198. <if test="round != null">round = #{round},</if>
  199. <if test="packageJson != null">package_json = #{packageJson},</if>
  200. <if test="isTranscode != null">is_transcode = #{isTranscode},</if>
  201. <if test="transcodeFileKey != null">transcode_file_key = #{transcodeFileKey},</if>
  202. <if test="viewStartTime != null">view_start_time = #{viewStartTime},</if>
  203. <if test="viewEndTime != null">view_end_time = #{viewEndTime},</if>
  204. <if test="lastJoinTime != null">last_join_time = #{lastJoinTime},</if>
  205. </trim>
  206. where video_id = #{videoId}
  207. </update>
  208. <update id="deleteFsUserCourseVideoByVideoId" parameterType="String">
  209. update fs_user_course_video set is_del = 1 where video_id = #{videoId}
  210. </update>
  211. <update id="deleteFsUserCourseVideoByVideoIds" parameterType="String">
  212. update fs_user_course_video set is_del = 1 where video_id in
  213. <foreach item="videoId" collection="array" open="(" separator="," close=")">
  214. #{videoId}
  215. </foreach>
  216. </update>
  217. <update id="updates">
  218. update fs_user_course_video set view_start_time = #{viewStartTime},view_end_time = #{viewEndTime},last_join_time = #{lastJoinTime} where video_id in
  219. <foreach item="videoId" collection="ids" open="(" separator="," close=")">
  220. #{videoId}
  221. </foreach>
  222. </update>
  223. <select id="selectFsUserCourseVideoPageList" resultType="FsUserCourseVideoPageListVO">
  224. SELECT
  225. DISTINCT video.video_id,
  226. video.title,
  227. video.description,
  228. video.video_url,
  229. video.thumbnail,
  230. video.duration,
  231. video.course_id,
  232. video.STATUS,
  233. video.course_sort,
  234. course.course_name,
  235. fcpd.period_id,
  236. fcpd.id,
  237. if(ccut.start_date_time is null, fcpd.start_date_time, ccut.start_date_time) as startDateTime,
  238. if(ccut.end_date_time is null, fcpd.end_date_time, ccut.end_date_time) as endDateTime
  239. FROM `fs_user_course_video` video
  240. left join fs_user_course_period_days fcpd on fcpd.video_id = video.video_id
  241. left join fs_user_course_period fcp on fcp.period_id = fcpd.period_id
  242. LEFT JOIN fs_user_course course ON video.course_id = course.course_id
  243. LEFT JOIN fs_user_course_company_user_time ccut ON ccut.period_id = fcpd.period_id
  244. AND ccut.course_id = fcpd.course_id
  245. AND ccut.video_id = fcpd.video_id
  246. AND ccut.company_user_id = #{companyUserId}
  247. where course.is_del = 0
  248. AND FIND_IN_SET(#{companyId}, fcp.company_id)
  249. <if test="periodId != null and periodId !='' ">
  250. AND fcpd.period_id = #{periodId}
  251. </if>
  252. <if test="keyword != null and keyword !='' ">
  253. AND video.title LIKE concat('%',#{keyword},'%')
  254. </if>
  255. order by video.course_sort
  256. </select>
  257. <select id="selectVideoListByMap" resultType="com.fs.his.vo.OptionsVO">
  258. select distinct
  259. ucv.video_id dictValue,
  260. ucv.title dictLabel
  261. from fs_user_course_video ucv
  262. left join fs_user_course_period_days ucpd on ucpd.video_id = ucv.video_id
  263. <where>
  264. <if test="params.name != null and params.name != ''">
  265. ucv.title like concat('%', #{params.name}, '%')
  266. </if>
  267. <if test="params.periodId != null">
  268. and ucpd.period_id = #{params.periodId}
  269. </if>
  270. </where>
  271. </select>
  272. <select id="selectFsUserCourseVideoListByMap" resultType="com.fs.course.vo.newfs.FsUserCourseVideoPageListVO">
  273. select
  274. video.video_id,
  275. video.title,
  276. video.description,
  277. video.video_url,
  278. video.thumbnail,
  279. video.duration,
  280. video.course_id,
  281. video.STATUS,
  282. video.course_sort,
  283. course.course_name,
  284. fcpd.period_id,
  285. fcpd.id,
  286. if(ccut.start_date_time is null, fcpd.start_date_time, ccut.start_date_time) as startDateTime,
  287. if(ccut.end_date_time is null, fcpd.end_date_time, ccut.end_date_time) as endDateTime
  288. from `fs_user_course_video` video
  289. left join fs_user_course_period_days fcpd on fcpd.video_id = video.video_id
  290. left join fs_user_course_period fcp on fcp.period_id = fcpd.period_id
  291. left join fs_user_course course ON video.course_id = course.course_id
  292. LEFT JOIN fs_user_course_company_user_time ccut ON ccut.period_id = fcpd.period_id
  293. AND ccut.course_id = fcpd.course_id
  294. AND ccut.video_id = fcpd.video_id
  295. AND ccut.company_user_id = #{params.companyUserId}
  296. where course.is_del = 0
  297. <if test="params.companyId != null">
  298. and FIND_IN_SET(#{params.companyId}, fcp.company_id)
  299. </if>
  300. and (
  301. (fcpd.start_date_time &lt;= CONCAT( CURDATE(), ' 23:59:59' ) and fcpd.end_date_time >= CONCAT( CURDATE(), ' 00:00:00' ))
  302. or (ccut.start_date_time &lt;= CONCAT( CURDATE(), ' 23:59:59' ) and ccut.end_date_time >= CONCAT( CURDATE(), ' 00:00:00' ))
  303. )
  304. order by video.course_sort
  305. </select>
  306. <select id="selectFsUserCourseVideoByVideoIdAndUserId" resultType="com.fs.course.domain.FsUserCourseVideo">
  307. </select>
  308. <update id="updateRedPacketMoney">
  309. update fs_user_course_video set red_packet_money = #{redPacketMoney} where video_id = #{videoId}
  310. </update>
  311. </mapper>