FsUserCourseVideoMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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="watchDurationMinutes" column="watch_duration_minutes" />
  21. <result property="integralReward" column="integral_reward" />
  22. <result property="fileName" column="file_name" />
  23. <result property="isDel" column="is_del" />
  24. <result property="questionBankId" column="question_bank_id" />
  25. <result property="lineOne" column="line_one" />
  26. <result property="lineTwo" column="line_two" />
  27. <result property="lineThree" column="line_three" />
  28. <result property="uploadType" column="upload_type" />
  29. <result property="redPacketMoney" column="red_packet_money" />
  30. <result property="fileSize" column="file_size" />
  31. <result property="fileKey" column="file_key" />
  32. <result property="round" column="round" />
  33. <result property="packageJson" column="package_json" />
  34. <result property="isTranscode" column="is_transcode" />
  35. <result property="transcodeFileKey" column="transcode_file_key" />
  36. <result property="viewStartTime" column="view_start_time" />
  37. <result property="viewEndTime" column="view_end_time" />
  38. <result property="lastJoinTime" column="last_join_time" />
  39. <result property="projectId" column="project_id" />
  40. <result property="isFirst" column="is_first" />
  41. <result property="courseIntroImg" column="course_intro_img" />
  42. <result property="courseCouponId" column="course_coupon_id" />
  43. </resultMap>
  44. <sql id="selectFsUserCourseVideoVo">
  45. select * from fs_user_course_video
  46. </sql>
  47. <select id="selectFsUserCourseVideoList" parameterType="FsUserCourseVideo" resultMap="FsUserCourseVideoResult">
  48. <include refid="selectFsUserCourseVideoVo"/>
  49. <where>
  50. <if test="fileId != null and fileId != ''"> and file_id = #{fileId}</if>
  51. <if test="title != null and title != ''"> and title = #{title}</if>
  52. <if test="description != null and description != ''"> and description = #{description}</if>
  53. <if test="videoUrl != null and videoUrl != ''"> and video_url = #{videoUrl}</if>
  54. <if test="thumbnail != null and thumbnail != ''"> and thumbnail = #{thumbnail}</if>
  55. <if test="duration != null "> and duration = #{duration}</if>
  56. <if test="talentId != null "> and talent_id = #{talentId}</if>
  57. <if test="courseId != null "> and course_id = #{courseId}</if>
  58. <if test="status != null "> and status = #{status}</if>
  59. <if test="courseSort != null "> and course_sort = #{courseSort}</if>
  60. <if test="questionBankId != null "> and question_bank_id = #{questionBankId}</if>
  61. <if test="userId != null "> and user_id = #{userId}</if>
  62. <if test="projectId != null "> and project_id = #{projectId}</if>
  63. <if test="userId != null "> and user_id = #{userId}</if>
  64. <if test="isDel != null "> and is_del = #{isDel}</if>
  65. </where>
  66. </select>
  67. <select id="selectFsUserCourseVideoByVideoId" parameterType="Long" resultMap="FsUserCourseVideoResult">
  68. <include refid="selectFsUserCourseVideoVo"/>
  69. where video_id = #{videoId}
  70. </select>
  71. <insert id="insertFsUserCourseVideo" parameterType="FsUserCourseVideo" useGeneratedKeys="true" keyProperty="videoId">
  72. insert into fs_user_course_video
  73. <trim prefix="(" suffix=")" suffixOverrides=",">
  74. <if test="fileId != null">file_id,</if>
  75. <if test="title != null">title,</if>
  76. <if test="description != null">description,</if>
  77. <if test="videoUrl != null">video_url,</if>
  78. <if test="thumbnail != null">thumbnail,</if>
  79. <if test="duration != null">duration,</if>
  80. <if test="updateTime != null">update_time,</if>
  81. <if test="createTime != null">create_time,</if>
  82. <if test="talentId != null">talent_id,</if>
  83. <if test="courseId != null">course_id,</if>
  84. <if test="status != null">status,</if>
  85. <if test="courseSort != null">course_sort,</if>
  86. <if test="watchDurationMinutes != null">watch_duration_minutes,</if>
  87. <if test="integralReward != null">integral_reward,</if>
  88. <if test="fileName != null">file_name,</if>
  89. <if test="isDel != null">is_del,</if>
  90. <if test="questionBankId != null">question_bank_id,</if>
  91. <if test="lineOne != null">line_one,</if>
  92. <if test="lineTwo != null">line_two,</if>
  93. <if test="lineThree != null">line_three,</if>
  94. <if test="uploadType != null">upload_type,</if>
  95. <if test="redPacketMoney != null">red_packet_money,</if>
  96. <if test="randomRedPacketRules != null">random_red_packet_rules,</if>
  97. <if test="fileSize != null">file_size,</if>
  98. <if test="fileKey != null">file_key,</if>
  99. <if test="round != null">round,</if>
  100. <if test="packageJson != null">package_json,</if>
  101. <if test="isTranscode != null">is_transcode,</if>
  102. <if test="transcodeFileKey != null">transcode_file_key,</if>
  103. <if test="viewStartTime != null">view_start_time,</if>
  104. <if test="viewEndTime != null">view_end_time,</if>
  105. <if test="lastJoinTime != null">last_join_time,</if>
  106. <if test="projectId != null">project_id,</if>
  107. <if test="isProduct != null">is_product,</if>
  108. <if test="productId != null">product_id,</if>
  109. <if test="listingStartTime != null">listing_start_time,</if>
  110. <if test="listingEndTime != null">listing_end_time,</if>
  111. <if test="userId != null">user_id,</if>
  112. <if test="isFirst != null">is_first,</if>
  113. <if test="isSpeed != null">is_speed,</if>
  114. <if test="jobId != null">job_id,</if>
  115. <if test="vid != null">vid,</if>
  116. <if test="courseIntroImg != null">course_intro_img,</if>
  117. <if test="courseCouponId != null">course_coupon_id,</if>
  118. </trim>
  119. <trim prefix="values (" suffix=")" suffixOverrides=",">
  120. <if test="fileId != null">#{fileId},</if>
  121. <if test="title != null">#{title},</if>
  122. <if test="description != null">#{description},</if>
  123. <if test="videoUrl != null">#{videoUrl},</if>
  124. <if test="thumbnail != null">#{thumbnail},</if>
  125. <if test="duration != null">#{duration},</if>
  126. <if test="updateTime != null">#{updateTime},</if>
  127. <if test="createTime != null">#{createTime},</if>
  128. <if test="talentId != null">#{talentId},</if>
  129. <if test="courseId != null">#{courseId},</if>
  130. <if test="status != null">#{status},</if>
  131. <if test="courseSort != null">#{courseSort},</if>
  132. <if test="watchDurationMinutes != null">#{watchDurationMinutes},</if>
  133. <if test="integralReward != null">#{integralReward},</if>
  134. <if test="fileName != null">#{fileName},</if>
  135. <if test="isDel != null">#{isDel},</if>
  136. <if test="questionBankId != null">#{questionBankId},</if>
  137. <if test="lineOne != null">#{lineOne},</if>
  138. <if test="lineTwo != null">#{lineTwo},</if>
  139. <if test="lineThree != null">#{lineThree},</if>
  140. <if test="uploadType != null">#{uploadType},</if>
  141. <if test="redPacketMoney != null">#{redPacketMoney},</if>
  142. <if test="randomRedPacketRules != null">#{randomRedPacketRules},</if>
  143. <if test="fileSize != null">#{fileSize},</if>
  144. <if test="fileKey != null">#{fileKey},</if>
  145. <if test="round != null">#{round},</if>
  146. <if test="packageJson != null">#{packageJson},</if>
  147. <if test="isTranscode != null">#{isTranscode},</if>
  148. <if test="transcodeFileKey != null">#{transcodeFileKey},</if>
  149. <if test="viewStartTime != null">#{viewStartTime},</if>
  150. <if test="viewEndTime != null">#{viewEndTime},</if>
  151. <if test="lastJoinTime != null">#{lastJoinTime},</if>
  152. <if test="projectId != null">#{projectId},</if>
  153. <if test="isProduct != null">#{isProduct},</if>
  154. <if test="productId != null">#{productId},</if>
  155. <if test="listingStartTime != null">#{listingStartTime},</if>
  156. <if test="listingEndTime != null">#{listingEndTime},</if>
  157. <if test="userId != null">#{userId},</if>
  158. <if test="isFirst != null">#{isFirst},</if>
  159. <if test="isSpeed != null">#{isSpeed},</if>
  160. <if test="jobId != null">#{jobId},</if>
  161. <if test="vid != null">#{vid},</if>
  162. <if test="courseIntroImg != null">#{courseIntroImg},</if>
  163. <if test="courseCouponId != null">#{courseCouponId},</if>
  164. </trim>
  165. </insert>
  166. <insert id="insertBatchFsUserCourseVideo" parameterType="FsUserCourseVideo" useGeneratedKeys="true" keyProperty="videoId">
  167. insert into fs_user_course_video
  168. (
  169. title,
  170. video_url,
  171. thumbnail,
  172. duration,
  173. course_id,
  174. status,
  175. course_sort,
  176. file_name,
  177. question_bank_id,
  178. line_one,
  179. line_two,
  180. line_three,
  181. red_packet_money,
  182. file_size,
  183. file_key,
  184. is_transcode,
  185. user_id,
  186. project_id
  187. )
  188. values
  189. <foreach collection="collect" item="item" separator=",">
  190. (
  191. #{item.title},
  192. #{item.videoUrl},
  193. #{item.thumbnail},
  194. #{item.duration},
  195. #{item.courseId},
  196. #{item.status},
  197. #{item.courseSort},
  198. #{item.fileName},
  199. #{item.questionBankId},
  200. #{item.lineOne},
  201. #{item.lineTwo},
  202. #{item.lineThree},
  203. #{item.redPacketMoney},
  204. #{item.fileSize},
  205. #{item.fileKey},
  206. #{item.isTranscode},
  207. #{item.userId},
  208. #{item.projectId}
  209. )
  210. </foreach>
  211. </insert>
  212. <update id="updateFsUserCourseVideo" parameterType="FsUserCourseVideo">
  213. update fs_user_course_video
  214. <trim prefix="SET" suffixOverrides=",">
  215. <if test="fileId != null">file_id = #{fileId},</if>
  216. <if test="title != null">title = #{title},</if>
  217. <if test="description != null">description = #{description},</if>
  218. <if test="videoUrl != null">video_url = #{videoUrl},</if>
  219. <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
  220. <if test="duration != null">duration = #{duration},</if>
  221. <if test="updateTime != null">update_time = #{updateTime},</if>
  222. <if test="createTime != null">create_time = #{createTime},</if>
  223. <if test="talentId != null">talent_id = #{talentId},</if>
  224. <if test="courseId != null">course_id = #{courseId},</if>
  225. <if test="status != null">status = #{status},</if>
  226. <if test="courseSort != null">course_sort = #{courseSort},</if>
  227. <if test="watchDurationMinutes != null">watch_duration_minutes = #{watchDurationMinutes},</if>
  228. <if test="integralReward != null">integral_reward = #{integralReward},</if>
  229. <if test="fileName != null">file_name = #{fileName},</if>
  230. <if test="isDel != null">is_del = #{isDel},</if>
  231. <if test="questionBankId != null">question_bank_id = #{questionBankId},</if>
  232. <if test="lineOne != null">line_one = #{lineOne},</if>
  233. <if test="lineTwo != null">line_two = #{lineTwo},</if>
  234. <if test="lineThree != null">line_three = #{lineThree},</if>
  235. <if test="uploadType != null">upload_type = #{uploadType},</if>
  236. <if test="redPacketMoney != null">red_packet_money = #{redPacketMoney},</if>
  237. <if test="randomRedPacketRules != null">random_red_packet_rules = #{randomRedPacketRules},</if>
  238. <if test="fileSize != null">file_size = #{fileSize},</if>
  239. <if test="fileKey != null">file_key = #{fileKey},</if>
  240. <if test="round != null">round = #{round},</if>
  241. <if test="packageJson != null">package_json = #{packageJson},</if>
  242. <if test="isTranscode != null">is_transcode = #{isTranscode},</if>
  243. <if test="transcodeFileKey != null">transcode_file_key = #{transcodeFileKey},</if>
  244. <if test="viewStartTime != null">view_start_time = #{viewStartTime},</if>
  245. <if test="viewEndTime != null">view_end_time = #{viewEndTime},</if>
  246. <if test="lastJoinTime != null">last_join_time = #{lastJoinTime},</if>
  247. <if test="isProduct != null">is_product = #{isProduct},</if>
  248. <if test="productId != null">product_id = #{productId},</if>
  249. <if test="listingStartTime != null">listing_start_time = #{listingStartTime},</if>
  250. <if test="listingEndTime != null">listing_end_time = #{listingEndTime},</if>
  251. <if test="projectId != null">project_id = #{projectId},</if>
  252. <if test="isFirst != null">is_first = #{isFirst},</if>
  253. <if test="isSpeed != null">is_speed = #{isSpeed},</if>
  254. <if test="isOnPut != null">is_on_put = #{isOnPut},</if>
  255. <if test="jobId != null">job_id = #{jobId},</if>
  256. <if test="vid != null">vid = #{vid},</if>
  257. <if test="courseIntroImg != null">course_intro_img = #{courseIntroImg},</if>
  258. <if test="courseIntroImg == null">course_intro_img = null,</if>
  259. <if test="courseCouponId != null">course_coupon_id = #{courseCouponId},</if>
  260. <if test="courseCouponId == null">course_coupon_id = null,</if>
  261. </trim>
  262. where video_id = #{videoId}
  263. </update>
  264. <update id="deleteFsUserCourseVideoByVideoId" parameterType="String">
  265. update fs_user_course_video set is_del = 1 where video_id = #{videoId}
  266. </update>
  267. <update id="deleteFsUserCourseVideoByVideoIds" parameterType="String">
  268. update fs_user_course_video set is_del = 1 where video_id in
  269. <foreach item="videoId" collection="array" open="(" separator="," close=")">
  270. #{videoId}
  271. </foreach>
  272. </update>
  273. <update id="batchUpdateWatchIntegralByVideoIds">
  274. update fs_user_course_video
  275. set watch_duration_minutes = #{watchDurationMinutes},
  276. integral_reward = #{integralReward},
  277. update_time = now()
  278. where is_del = 0
  279. and course_id = #{courseId}
  280. and video_id in
  281. <foreach collection="videoIds" item="vid" open="(" separator="," close=")">
  282. #{vid}
  283. </foreach>
  284. </update>
  285. <update id="updates">
  286. update fs_user_course_video set view_start_time = #{viewStartTime},view_end_time = #{viewEndTime},last_join_time = #{lastJoinTime} where video_id in
  287. <foreach item="videoId" collection="ids" open="(" separator="," close=")">
  288. #{videoId}
  289. </foreach>
  290. </update>
  291. <select id="selectFsUserCourseVideoPageList" resultType="com.fs.course.vo.newfs.FsUserCourseVideoPageListVO">
  292. SELECT
  293. DISTINCT video.video_id,
  294. video.title,
  295. video.description,
  296. video.video_url,
  297. video.thumbnail,
  298. video.duration,
  299. video.course_id,
  300. video.STATUS,
  301. video.course_sort,
  302. video.is_speed,
  303. course.course_name,
  304. fcpd.period_id,
  305. fcp.period_name,
  306. fcpd.id,
  307. if(fav.id is null, 0, 1) as isFavorite,
  308. if(ccut.start_date_time is null, fcpd.start_date_time, ccut.start_date_time) as startDateTime,
  309. if(ccut.end_date_time is null, fcpd.end_date_time, ccut.end_date_time) as endDateTime,
  310. course.project as projectId,
  311. fcp.max_view_num as maxViewNum
  312. FROM `fs_user_course_video` video
  313. left join fs_user_course_period_days fcpd on fcpd.video_id = video.video_id
  314. left join fs_user_course_period fcp on fcp.period_id = fcpd.period_id
  315. LEFT JOIN fs_user_course course ON video.course_id = course.course_id
  316. LEFT JOIN fs_user_course_company_user_time ccut ON ccut.period_id = fcpd.period_id
  317. AND ccut.course_id = fcpd.course_id
  318. AND ccut.video_id = fcpd.video_id
  319. AND ccut.company_user_id = #{companyUserId}
  320. left join fs_company_user_course_favorite fav
  321. on fav.period_id = fcpd.period_id
  322. and fav.company_user_id = #{companyUserId}
  323. where course.is_del = 0 and fcp.del_flag = 0 and fcpd.del_flag = 0
  324. AND FIND_IN_SET(#{companyId}, fcp.company_id)
  325. <if test="periodId != null and periodId !='' ">
  326. AND fcpd.period_id = #{periodId}
  327. </if>
  328. <if test="keyword != null and keyword !='' ">
  329. AND video.title LIKE concat('%',#{keyword},'%')
  330. </if>
  331. <!-- 营销提前查看天数逻辑 -->
  332. AND DATE_SUB(fcpd.day_date, INTERVAL fcp.max_view_num DAY) &lt;= now()
  333. order by fcpd.start_date_time desc , ccut.start_date_time, video.course_sort
  334. </select>
  335. <select id="selectVideoListByMap" resultType="com.fs.his.vo.OptionsVO">
  336. select distinct
  337. ucv.video_id dictValue,
  338. ucv.title dictLabel
  339. from fs_user_course_video ucv
  340. left join fs_user_course_period_days ucpd on ucpd.video_id = ucv.video_id
  341. <where>
  342. <if test="params.name != null and params.name != ''">
  343. ucv.title like concat('%', #{params.name}, '%')
  344. </if>
  345. <if test="params.periodId != null">
  346. and ucpd.period_id = #{params.periodId}
  347. </if>
  348. </where>
  349. </select>
  350. <select id="selectFsUserCourseVideoListByMap" resultType="com.fs.course.vo.newfs.FsUserCourseVideoPageListVO">
  351. select
  352. video.video_id,
  353. video.title,
  354. video.description,
  355. video.video_url,
  356. video.thumbnail,
  357. video.duration,
  358. video.course_id,
  359. video.STATUS,
  360. video.course_sort,
  361. video.is_speed,
  362. course.course_name,
  363. fcpd.period_id,
  364. fcp.period_name,
  365. fcpd.start_date_time,
  366. fcpd.end_date_time,
  367. fcpd.last_join_time,
  368. fcpd.id,
  369. fcp.period_name,
  370. if(fav.id is null, 0, 1) as isFavorite,
  371. if(ccut.start_date_time is null, fcpd.start_date_time, ccut.start_date_time) as startDateTime,
  372. if(ccut.end_date_time is null, fcpd.end_date_time, ccut.end_date_time) as endDateTime,
  373. course.project as projectId
  374. from `fs_user_course_video` video
  375. left join fs_user_course_period_days fcpd on fcpd.video_id = video.video_id
  376. left join fs_user_course_period fcp on fcp.period_id = fcpd.period_id
  377. left join fs_user_course course ON video.course_id = course.course_id
  378. left join fs_company_user_course_favorite fav
  379. on fav.period_id = fcpd.period_id
  380. and fav.company_user_id = #{params.companyUserId}
  381. LEFT JOIN fs_user_course_company_user_time ccut ON ccut.period_id = fcpd.period_id
  382. AND ccut.course_id = fcpd.course_id
  383. AND ccut.video_id = fcpd.video_id
  384. AND ccut.company_user_id = #{params.companyUserId}
  385. where course.is_del = 0 and fcp.del_flag = '0' and fcpd.del_flag = '0'
  386. <if test="params.companyId != null">
  387. and FIND_IN_SET(#{params.companyId}, fcp.company_id)
  388. </if>
  389. <if test="params.dayDate != null">
  390. and fcpd.day_date = #{params.dayDate}
  391. </if>
  392. <if test="params.keyword != null and params.keyword !='' ">
  393. AND video.title LIKE concat('%',#{params.keyword},'%')
  394. </if>
  395. and (
  396. (fcpd.start_date_time &lt;= CONCAT( CURDATE(), ' 23:59:59' ) and fcpd.end_date_time >= CONCAT( CURDATE(), ' 00:00:00' ))
  397. or (ccut.start_date_time &lt;= CONCAT( CURDATE(), ' 23:59:59' ) and ccut.end_date_time >= CONCAT( CURDATE(), ' 00:00:00' ))
  398. )
  399. order by if(fav.id is null, 0, 1) desc,
  400. if(ccut.start_date_time is null, fcpd.start_date_time, ccut.start_date_time) desc,
  401. video.course_sort
  402. </select>
  403. <select id="selectFsUserCourseVideoVoByVideoId" resultType="com.fs.course.vo.FsUserCourseVO">
  404. select
  405. video.video_id,
  406. video.title,
  407. course.course_id,
  408. course.course_name,
  409. fcp.period_id,
  410. fcp.period_name,
  411. c.training_camp_id,
  412. c.training_camp_name
  413. from `fs_user_course_video` video
  414. left join fs_user_course course ON video.course_id = course.course_id
  415. left join fs_user_course_period_days fcpd on fcpd.video_id = video.video_id
  416. left join fs_user_course_period fcp on fcp.period_id = fcpd.period_id
  417. left join fs_user_course_training_camp c on fcp.training_camp_id = c.training_camp_id
  418. where course.is_del = 0 and video.video_id = #{videoId}
  419. and fcp.period_id = #{periodId}
  420. and fcpd.del_flag = 0 and video.is_del = 0 and fcp.del_flag = '0' and c.del_flag = '0'
  421. limit 1
  422. </select>
  423. <select id="selectFsUserCourseVideoByVideoIdAndUserId" resultMap="FsUserCourseVideoResult">
  424. <include refid="selectFsUserCourseVideoVo"/>
  425. where video_id=#{videoId} and is_del = 0
  426. <if test="userId != null">
  427. and user_id = #{userId}
  428. </if>
  429. </select>
  430. <update id="updateRedPacketMoney">
  431. update fs_user_course_video set red_packet_money = #{redPacketMoney},title = #{title} where video_id = #{videoId}
  432. </update>
  433. <update id="batchUpdateByVideoId">
  434. UPDATE fs_user_course_video
  435. SET course_sort =
  436. <foreach collection="list" item="item" index="index" separator=" " open="CASE video_id" close="END">
  437. WHEN #{item.videoId} THEN #{item.courseSort}
  438. </foreach>
  439. WHERE video_id IN
  440. <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
  441. #{item.videoId}
  442. </foreach>
  443. </update>
  444. <select id="selectByFileKey" resultMap="FsUserCourseVideoResult">
  445. <include refid="selectFsUserCourseVideoVo"/>
  446. <where>
  447. <if test="fileKey != null and fileKey != ''"> and file_key = #{fileKey}</if>
  448. </where>
  449. limit 1
  450. </select>
  451. <select id="getChooseCourseVideoListByMap" resultType="com.fs.course.vo.FsUserCourseVideoChooseVO">
  452. select
  453. fucv.video_id,
  454. fuc.course_name,
  455. fucv.title courseVideoName,
  456. fucv.file_name videoName,
  457. fucv.duration
  458. from fs_user_course_video fucv
  459. inner join fs_user_course fuc on fuc.course_id = fucv.course_id
  460. where fuc.is_private = 1 and fuc.is_del = 0 and fucv.is_del = 0
  461. <if test="params.courseId != null">
  462. and fucv.course_id = #{params.courseId}
  463. </if>
  464. <if test="params.userId != null">
  465. and fuc.user_id = #{params.userId} and fucv.user_id = #{params.userId}
  466. </if>
  467. <if test="params.videoIds != null">
  468. and fucv.video_id in
  469. <foreach collection="params.videoIds" item="videoId" open="(" separator="," close=")">
  470. #{videoId}
  471. </foreach>
  472. </if>
  473. order by fuc.course_id, fucv.video_id
  474. </select>
  475. <resultMap id="FsUserCourseVideoAppletVOMap" type="com.fs.course.vo.FsUserCourseVideoAppletVO">
  476. <id property="courseId" column="course_id"/>
  477. <result property="courseName" column="course_name"/>
  478. <result property="description" column="description"/>
  479. <result property="imgUrl" column="img_url"/>
  480. <result property="secondImg" column="second_img"/>
  481. <result property="views" column="views"/>
  482. <result property="videoTotal" column="video_total"/>
  483. <collection property="fsUserCourseVideoList" ofType="com.fs.course.vo.FsUserCourseVideoAppletVO$FsUserCourseVideo">
  484. <result property="videoId" column="video_id"/>
  485. <result property="title" column="title"/>
  486. <result property="videoImgUrl" column="video_img_url"/>
  487. <result property="videoUrl" column="video_url"/>
  488. <result property="videoDescription" column="video_description"/>
  489. <result property="totalDuration" column="total_duration"/>
  490. <result property="questionBankId" column="question_bank_id"/>
  491. </collection>
  492. </resultMap>
  493. <select id="getFsUserCourseVideoAppletVOListByIds" resultMap="FsUserCourseVideoAppletVOMap">
  494. SELECT
  495. c.course_id AS course_id,
  496. c.course_name AS course_name,
  497. c.description AS description,
  498. c.img_url AS img_url,
  499. c.second_img AS second_img,
  500. c.views AS views,
  501. 1 AS video_total,
  502. v.video_id AS video_id,
  503. v.title AS title,
  504. v.thumbnail AS video_img_url,
  505. v.video_url AS video_url,
  506. v.description AS video_description,
  507. SEC_TO_TIME(v.duration) AS total_duration,
  508. v.question_bank_id AS question_bank_id
  509. FROM fs_user_course c
  510. LEFT JOIN fs_user_course_video v ON v.course_id = c.course_id
  511. WHERE v.video_id in
  512. <foreach collection="videoIds" item="videoId" open="(" separator="," close=")">
  513. #{videoId}
  514. </foreach>
  515. </select>
  516. <select id="selectFsUserCourseVideoVoByVideoIdAndCourdeId" resultType="com.fs.course.vo.FsUserCourseVO">
  517. select
  518. video.video_id,
  519. video.title,
  520. course.course_id,
  521. course.course_name
  522. from `fs_user_course_video` video
  523. left join fs_user_course course ON video.course_id = course.course_id
  524. where course.is_del = 0 and video.video_id = #{videoId}
  525. and video.is_del = 0 and video.course_id= #{courseId}
  526. limit 1
  527. </select>
  528. <select id="selectVideoNamesByIds" resultType="java.util.Map">
  529. SELECT CAST(video_id AS SIGNED) AS videoId, title AS videoName
  530. FROM fs_user_course_video
  531. WHERE is_del = 0 AND video_id IN
  532. <foreach collection="videoIds" item="id" open="(" separator="," close=")">
  533. #{id}
  534. </foreach>
  535. </select>
  536. <update id="batchDown" parameterType="String">
  537. update fs_user_course_video set is_on_put = 1 where video_id in
  538. <foreach item="videoId" collection="array" open="(" separator="," close=")">
  539. #{videoId}
  540. </foreach>
  541. </update>
  542. <update id="batchUp" parameterType="String">
  543. update fs_user_course_video set is_on_put = 0 where video_id in
  544. <foreach item="videoId" collection="array" open="(" separator="," close=")">
  545. #{videoId}
  546. </foreach>
  547. </update>
  548. <update id="batchEditCover" parameterType="com.fs.course.param.BatchEditCoverParam">
  549. update fs_user_course_video set thumbnail = #{thumbnail} where video_id in
  550. <foreach item="videoId" collection="videoIds" open="(" separator="," close=")">
  551. #{videoId}
  552. </foreach>
  553. </update>
  554. </mapper>