FsUserCourseMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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.FsUserCourseMapper">
  6. <resultMap type="FsUserCourse" id="FsUserCourseResult">
  7. <result property="courseId" column="course_id" />
  8. <result property="cateId" column="cate_id" />
  9. <result property="subCateId" column="sub_cate_id" />
  10. <result property="courseName" column="course_name" />
  11. <result property="title" column="title" />
  12. <result property="imgUrl" column="img_url" />
  13. <result property="sort" column="sort" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="status" column="status" />
  17. <result property="isVip" column="is_vip" />
  18. <result property="isHot" column="is_hot" />
  19. <result property="isShow" column="is_show" />
  20. <result property="views" column="views" />
  21. <result property="duration" column="duration" />
  22. <result property="description" column="description" />
  23. <result property="hotRanking" column="hot_ranking" />
  24. <result property="integral" column="integral" />
  25. <result property="price" column="price" />
  26. <result property="sellPrice" column="sell_price" />
  27. <result property="project" column="project" />
  28. <result property="tags" column="tags" />
  29. <result property="likes" column="likes" />
  30. <result property="favoriteNum" column="favorite_num" />
  31. <result property="shares" column="shares" />
  32. <result property="isAutoPlay" column="is_auto_play" />
  33. <result property="isFast" column="is_fast" />
  34. <result property="isBest" column="is_best" />
  35. <result property="isTui" column="is_tui" />
  36. <result property="hotNum" column="hot_num" />
  37. <result property="isIntegral" column="is_integral" />
  38. <result property="courseType" column="course_type" />
  39. <result property="talentId" column="talent_id" />
  40. <result property="isDel" column="is_del" />
  41. <result property="isNext" column="is_next" />
  42. <result property="isPrivate" column="is_private" />
  43. <result property="secondImg" column="second_img" />
  44. <result property="companyIds" column="company_ids" />
  45. </resultMap>
  46. <sql id="selectFsUserCourseVo">
  47. select course_id,is_private,company_ids,is_next,talent_id,second_img,is_del, cate_id,sub_cate_id, course_name, title, img_url, sort, create_time, update_time, status, is_vip, is_hot, is_show, views, duration, description, hot_ranking, integral, price, sell_price, project, tags, likes, favorite_num, shares, is_auto_play, is_fast, is_best, is_tui, hot_num, is_integral, course_type from fs_user_course
  48. </sql>
  49. <select id="selectFsUserCourseList" parameterType="FsUserCourse" resultMap="FsUserCourseResult">
  50. <include refid="selectFsUserCourseVo"/>
  51. <where>
  52. <if test="cateId != null "> and cate_id = #{cateId}</if>
  53. <if test="subCateId != null "> and sub_cate_id = #{subCateId}</if>
  54. <if test="courseName != null and courseName != ''"> and course_name like concat('%', #{courseName}, '%')</if>
  55. <if test="title != null and title != ''"> and title = #{title}</if>
  56. <if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
  57. <if test="sort != null "> and sort = #{sort}</if>
  58. <if test="status != null "> and status = #{status}</if>
  59. <if test="isVip != null "> and is_vip = #{isVip}</if>
  60. <if test="isHot != null "> and is_hot = #{isHot}</if>
  61. <if test="isShow != null "> and is_show = #{isShow}</if>
  62. <if test="views != null "> and views = #{views}</if>
  63. <if test="duration != null "> and duration = #{duration}</if>
  64. <if test="description != null and description != ''"> and description = #{description}</if>
  65. <if test="hotRanking != null "> and hot_ranking = #{hotRanking}</if>
  66. <if test="integral != null "> and integral = #{integral}</if>
  67. <if test="price != null "> and price = #{price}</if>
  68. <if test="sellPrice != null "> and sell_price = #{sellPrice}</if>
  69. <if test="project != null "> and project = #{project}</if>
  70. <if test="tags != null and tags != ''"> and tags = #{tags}</if>
  71. <if test="likes != null "> and likes = #{likes}</if>
  72. <if test="favoriteNum != null "> and favorite_num = #{favoriteNum}</if>
  73. <if test="shares != null "> and shares = #{shares}</if>
  74. <if test="isAutoPlay != null "> and is_auto_play = #{isAutoPlay}</if>
  75. <if test="isFast != null "> and is_fast = #{isFast}</if>
  76. <if test="isBest != null "> and is_best = #{isBest}</if>
  77. <if test="isTui != null "> and is_tui = #{isTui}</if>
  78. <if test="hotNum != null "> and hot_num = #{hotNum}</if>
  79. <if test="isIntegral != null "> and is_integral = #{isIntegral}</if>
  80. <if test="courseType != null "> and course_type = #{courseType}</if>
  81. <if test="talentId != null "> and talent_id = #{talentId}</if>
  82. <if test="isNext != null "> and is_next = #{isNext}</if>
  83. <if test="isPrivate != null "> and is_private = #{isPrivate}</if>
  84. <if test="userId != null "> and user_id = #{userId}</if>
  85. </where>
  86. </select>
  87. <select id="selectFsUserCourseByCourseId" parameterType="Long" resultMap="FsUserCourseResult">
  88. <include refid="selectFsUserCourseVo"/>
  89. where course_id = #{courseId}
  90. </select>
  91. <insert id="insertFsUserCourse" parameterType="FsUserCourse" useGeneratedKeys="true" keyProperty="courseId">
  92. insert into fs_user_course
  93. <trim prefix="(" suffix=")" suffixOverrides=",">
  94. <if test="cateId != null">cate_id,</if>
  95. <if test="subCateId != null">sub_cate_id,</if>
  96. <if test="courseName != null">course_name,</if>
  97. <if test="title != null">title,</if>
  98. <if test="imgUrl != null">img_url,</if>
  99. <if test="sort != null">sort,</if>
  100. <if test="createTime != null">create_time,</if>
  101. <if test="updateTime != null">update_time,</if>
  102. <if test="status != null">status,</if>
  103. <if test="isVip != null">is_vip,</if>
  104. <if test="isHot != null">is_hot,</if>
  105. <if test="isShow != null">is_show,</if>
  106. <if test="views != null">views,</if>
  107. <if test="duration != null">duration,</if>
  108. <if test="description != null">description,</if>
  109. <if test="hotRanking != null">hot_ranking,</if>
  110. <if test="integral != null">integral,</if>
  111. <if test="price != null">price,</if>
  112. <if test="sellPrice != null">sell_price,</if>
  113. <if test="project != null">project,</if>
  114. <if test="tags != null">tags,</if>
  115. <if test="likes != null">likes,</if>
  116. <if test="favoriteNum != null">favorite_num,</if>
  117. <if test="shares != null">shares,</if>
  118. <if test="isAutoPlay != null">is_auto_play,</if>
  119. <if test="isFast != null">is_fast,</if>
  120. <if test="isBest != null">is_best,</if>
  121. <if test="isTui != null">is_tui,</if>
  122. <if test="hotNum != null">hot_num,</if>
  123. <if test="isIntegral != null">is_integral,</if>
  124. <if test="courseType != null">course_type,</if>
  125. <if test="talentId != null">talent_id,</if>
  126. <if test="isDel != null">is_del,</if>
  127. <if test="isNext != null">is_next,</if>
  128. <if test="isPrivate != null">is_private,</if>
  129. <if test="secondImg != null">second_img,</if>
  130. <if test="companyIds != null">company_ids,</if>
  131. <if test="userId != null">user_id,</if>
  132. </trim>
  133. <trim prefix="values (" suffix=")" suffixOverrides=",">
  134. <if test="cateId != null">#{cateId},</if>
  135. <if test="subCateId != null">#{subCateId},</if>
  136. <if test="courseName != null">#{courseName},</if>
  137. <if test="title != null">#{title},</if>
  138. <if test="imgUrl != null">#{imgUrl},</if>
  139. <if test="sort != null">#{sort},</if>
  140. <if test="createTime != null">#{createTime},</if>
  141. <if test="updateTime != null">#{updateTime},</if>
  142. <if test="status != null">#{status},</if>
  143. <if test="isVip != null">#{isVip},</if>
  144. <if test="isHot != null">#{isHot},</if>
  145. <if test="isShow != null">#{isShow},</if>
  146. <if test="views != null">#{views},</if>
  147. <if test="duration != null">#{duration},</if>
  148. <if test="description != null">#{description},</if>
  149. <if test="hotRanking != null">#{hotRanking},</if>
  150. <if test="integral != null">#{integral},</if>
  151. <if test="price != null">#{price},</if>
  152. <if test="sellPrice != null">#{sellPrice},</if>
  153. <if test="project != null">#{project},</if>
  154. <if test="tags != null">#{tags},</if>
  155. <if test="likes != null">#{likes},</if>
  156. <if test="favoriteNum != null">#{favoriteNum},</if>
  157. <if test="shares != null">#{shares},</if>
  158. <if test="isAutoPlay != null">#{isAutoPlay},</if>
  159. <if test="isFast != null">#{isFast},</if>
  160. <if test="isBest != null">#{isBest},</if>
  161. <if test="isTui != null">#{isTui},</if>
  162. <if test="hotNum != null">#{hotNum},</if>
  163. <if test="isIntegral != null">#{isIntegral},</if>
  164. <if test="courseType != null">#{courseType},</if>
  165. <if test="talentId != null">#{talentId},</if>
  166. <if test="isDel != null">#{isDel},</if>
  167. <if test="isNext != null">#{isNext},</if>
  168. <if test="isPrivate != null">#{isPrivate},</if>
  169. <if test="secondImg != null">#{secondImg},</if>
  170. <if test="companyIds != null">#{companyIds},</if>
  171. <if test="userId != null">#{userId},</if>
  172. </trim>
  173. </insert>
  174. <update id="updateFsUserCourse" parameterType="FsUserCourse">
  175. update fs_user_course
  176. <trim prefix="SET" suffixOverrides=",">
  177. <if test="cateId != null">cate_id = #{cateId},</if>
  178. <if test="subCateId != null">sub_cate_id = #{subCateId},</if>
  179. <if test="courseName != null">course_name = #{courseName},</if>
  180. <if test="title != null">title = #{title},</if>
  181. <if test="imgUrl != null">img_url = #{imgUrl},</if>
  182. <if test="sort != null">sort = #{sort},</if>
  183. <if test="createTime != null">create_time = #{createTime},</if>
  184. <if test="updateTime != null">update_time = #{updateTime},</if>
  185. <if test="status != null">status = #{status},</if>
  186. <if test="isVip != null">is_vip = #{isVip},</if>
  187. <if test="isHot != null">is_hot = #{isHot},</if>
  188. <if test="isShow != null">is_show = #{isShow},</if>
  189. <if test="views != null">views = #{views},</if>
  190. <if test="duration != null">duration = #{duration},</if>
  191. <if test="description != null">description = #{description},</if>
  192. <if test="hotRanking != null">hot_ranking = #{hotRanking},</if>
  193. <if test="integral != null">integral = #{integral},</if>
  194. <if test="price != null">price = #{price},</if>
  195. <if test="sellPrice != null">sell_price = #{sellPrice},</if>
  196. <if test="project != null">project = #{project},</if>
  197. <if test="tags != null">tags = #{tags},</if>
  198. <if test="likes != null">likes = #{likes},</if>
  199. <if test="favoriteNum != null">favorite_num = #{favoriteNum},</if>
  200. <if test="shares != null">shares = #{shares},</if>
  201. <if test="isAutoPlay != null">is_auto_play = #{isAutoPlay},</if>
  202. <if test="isFast != null">is_fast = #{isFast},</if>
  203. <if test="isBest != null">is_best = #{isBest},</if>
  204. <if test="isTui != null">is_tui = #{isTui},</if>
  205. <if test="hotNum != null">hot_num = #{hotNum},</if>
  206. <if test="isIntegral != null">is_integral = #{isIntegral},</if>
  207. <if test="courseType != null">course_type = #{courseType},</if>
  208. <if test="talentId != null">talent_id = #{talentId},</if>
  209. <if test="isDel != null">is_del = #{isDel},</if>
  210. <if test="isNext != null">is_next = #{isNext},</if>
  211. <if test="isPrivate != null">is_private = #{isPrivate},</if>
  212. <if test="secondImg != null">second_img = #{secondImg},</if>
  213. <if test="companyIds != null">company_ids = #{companyIds},</if>
  214. </trim>
  215. where course_id = #{courseId}
  216. </update>
  217. <update id="deleteFsUserCourseByCourseId" parameterType="Long">
  218. update fs_user_course set is_del = 1 where course_id = #{courseId}
  219. </update>
  220. <update id="deleteFsUserCourseByCourseIds" parameterType="String">
  221. update fs_user_course set is_del = 1 where course_id in
  222. <foreach item="courseId" collection="array" open="(" separator="," close=")">
  223. #{courseId}
  224. </foreach>
  225. </update>
  226. <select id="getFsUserCourseList" resultType="FsUserCourseListVO">
  227. SELECT DISTINCT
  228. fcp.period_id,
  229. fcp.period_name
  230. FROM
  231. fs_user_course_period fcp
  232. LEFT JOIN fs_user_course_period_days fcpd ON fcpd.period_id = fcp.period_id
  233. LEFT JOIN fs_user_course c ON c.course_id = fcpd.course_id
  234. WHERE
  235. c.is_del = 0
  236. AND FIND_IN_SET(#{companyId}, fcp.company_id)
  237. <if test="keyword != null and keyword !='' ">
  238. AND fcp.period_name LIKE concat('%',#{keyword},'%'
  239. )
  240. </if>
  241. ORDER BY
  242. fcp.create_time desc, fcp.period_status asc
  243. </select>
  244. <!-- 查询用户参与记录 -->
  245. <select id="getParticipationRecordByMap" resultType="com.fs.course.vo.FsUserCourseParticipationRecordVO">
  246. select
  247. fu.user_id,
  248. fucv.video_id,
  249. fu.nickname as nickName,
  250. fu.username as userName,
  251. fu.avatar,
  252. fu.phone as phoneNumber,
  253. fu.create_time,
  254. max(fcwl.create_time) as watchDate
  255. from fs_user_course_video fucv
  256. inner join fs_course_watch_log fcwl on fcwl.video_id = fucv.video_id
  257. inner join fs_user fu on fu.user_id = fcwl.user_id
  258. where fucv.video_id = #{params.videoId}
  259. <if test="params.companyId != null">
  260. and fcwl.company_id = #{params.companyId}
  261. </if>
  262. <if test="params.companyUserId != null">
  263. and fcwl.company_user_id = #{params.companyUserId}
  264. </if>
  265. <if test="params.keyword != null and params.keyword != ''">
  266. and (
  267. fu.user_id = #{params.keyword}
  268. or fu.nickname like concat('%', #{params.keyword}, '%')
  269. or fu.username like concat('%', #{params.keyword}, '%')
  270. or fu.phone = #{params.keyword}
  271. )
  272. </if>
  273. <choose>
  274. <when test="params.type == 0">
  275. and (
  276. select count(log.log_id) as count
  277. from fs_course_answer_logs log
  278. where log.user_id = fu.user_id and log.video_id = fucv.video_id and log.is_right = 1
  279. ) > 0
  280. and (
  281. select count(log.log_id) as count
  282. from fs_course_red_packet_log log
  283. where log.user_id = fu.user_id and log.video_id = fucv.video_id and log.status = 1
  284. ) > 0
  285. </when>
  286. <when test="params.type == 1">
  287. and fcwl.log_type = 2
  288. </when>
  289. <when test="params.type == 2">
  290. and fcwl.log_type = 4
  291. </when>
  292. </choose>
  293. group by fu.user_id, fucv.video_id, fu.nickname, fu.username, fu.avatar, fu.phone, fu.create_time
  294. </select>
  295. <select id="selectFsUserCourseListCompanyPVO" resultType="com.fs.course.vo.FsUserCourseListPVO">
  296. select c.*,cc.cate_name,ucc.cate_name as sub_cate_name from fs_user_course c
  297. left join fs_user_course_category cc on c.cate_id=cc.cate_id
  298. left join fs_user_course_category ucc on ucc.cate_id = c.sub_cate_id
  299. where c.is_del = 0 and
  300. FIND_IN_SET(#{maps.companyId}, company_ids)
  301. <if test = ' maps.cateId !=null '>
  302. and (cc.cate_id =#{maps.cateId} or cc.pid=#{maps.cateId} )
  303. </if>
  304. <if test = ' maps.courseName!=null and maps.courseName != "" '>
  305. and c.course_name like concat('%', #{maps.courseName}, '%')
  306. </if>
  307. <if test = ' maps.isPrivate !=null '>
  308. and c.is_private = #{maps.isPrivate}
  309. </if>
  310. <if test = ' maps.isShow !=null '>
  311. and c.is_show = #{maps.isShow}
  312. </if>
  313. <if test="maps.project != null">
  314. and c.project = #{maps.project}
  315. </if>
  316. order by c.course_id
  317. </select>
  318. </mapper>