FsUserCourseVideoMapper.xml 18 KB

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