FsUserCourseVideoMapper.xml 17 KB

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