FsUserCourseMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. <result property="configJson" column="config_json" />
  46. <result property="recHomeCourseTopEnabled" column="rec_home_course_top_enabled"/>
  47. <result property="recHomeCourseTopMode" column="rec_home_course_top_mode"/>
  48. <result property="recHomeCourseTopSort" column="rec_home_course_top_sort"/>
  49. <result property="recMallHomeEnabled" column="rec_mall_home_enabled"/>
  50. <result property="recMallHomeMode" column="rec_mall_home_mode"/>
  51. <result property="recMallHomeSort" column="rec_mall_home_sort"/>
  52. <result property="recHomeLongVideoEnabled" column="rec_home_long_video_enabled"/>
  53. <result property="recHomeLongVideoMode" column="rec_home_long_video_mode"/>
  54. <result property="recHomeLongVideoSort" column="rec_home_long_video_sort"/>
  55. </resultMap>
  56. <sql id="selectFsUserCourseVo">
  57. 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, config_json,
  58. rec_home_course_top_enabled, rec_home_course_top_mode, rec_home_course_top_sort,
  59. rec_mall_home_enabled, rec_mall_home_mode, rec_mall_home_sort,
  60. rec_home_long_video_enabled, rec_home_long_video_mode, rec_home_long_video_sort
  61. from fs_user_course
  62. </sql>
  63. <select id="selectFsUserCourseList" parameterType="FsUserCourse" resultMap="FsUserCourseResult">
  64. <include refid="selectFsUserCourseVo"/>
  65. <where>
  66. <if test="cateId != null "> and cate_id = #{cateId}</if>
  67. <if test="subCateId != null "> and sub_cate_id = #{subCateId}</if>
  68. <if test="courseName != null and courseName != ''"> and course_name like concat('%', #{courseName}, '%')</if>
  69. <if test="title != null and title != ''"> and title = #{title}</if>
  70. <if test="imgUrl != null and imgUrl != ''"> and img_url = #{imgUrl}</if>
  71. <if test="sort != null "> and sort = #{sort}</if>
  72. <if test="status != null "> and status = #{status}</if>
  73. <if test="isVip != null "> and is_vip = #{isVip}</if>
  74. <if test="isHot != null "> and is_hot = #{isHot}</if>
  75. <if test="isShow != null "> and is_show = #{isShow}</if>
  76. <if test="views != null "> and views = #{views}</if>
  77. <if test="duration != null "> and duration = #{duration}</if>
  78. <if test="description != null and description != ''"> and description = #{description}</if>
  79. <if test="hotRanking != null "> and hot_ranking = #{hotRanking}</if>
  80. <if test="integral != null "> and integral = #{integral}</if>
  81. <if test="price != null "> and price = #{price}</if>
  82. <if test="sellPrice != null "> and sell_price = #{sellPrice}</if>
  83. <if test="project != null "> and project = #{project}</if>
  84. <if test="tags != null and tags != ''"> and tags = #{tags}</if>
  85. <if test="likes != null "> and likes = #{likes}</if>
  86. <if test="favoriteNum != null "> and favorite_num = #{favoriteNum}</if>
  87. <if test="shares != null "> and shares = #{shares}</if>
  88. <if test="isAutoPlay != null "> and is_auto_play = #{isAutoPlay}</if>
  89. <if test="isFast != null "> and is_fast = #{isFast}</if>
  90. <if test="isBest != null "> and is_best = #{isBest}</if>
  91. <if test="isTui != null "> and is_tui = #{isTui}</if>
  92. <if test="hotNum != null "> and hot_num = #{hotNum}</if>
  93. <if test="isIntegral != null "> and is_integral = #{isIntegral}</if>
  94. <if test="courseType != null "> and course_type = #{courseType}</if>
  95. <if test="talentId != null "> and talent_id = #{talentId}</if>
  96. <if test="isNext != null "> and is_next = #{isNext}</if>
  97. <if test="isPrivate != null ">
  98. <choose>
  99. <when test="isPrivate == 1"> and (is_private = 1 or is_private is null)</when>
  100. <otherwise> and is_private = #{isPrivate}</otherwise>
  101. </choose>
  102. </if>
  103. <if test="userId != null "> and user_id = #{userId}</if>
  104. <if test="configJson != null "> and config_json = #{configJson}</if>
  105. </where>
  106. </select>
  107. <select id="selectFsUserCourseByCourseId" parameterType="Long" resultMap="FsUserCourseResult">
  108. <include refid="selectFsUserCourseVo"/>
  109. where course_id = #{courseId}
  110. </select>
  111. <select id="getParticipationRecordByMap" resultType="com.fs.course.vo.FsUserCourseParticipationRecordVO">
  112. select
  113. fu.user_id,
  114. fucv.video_id,
  115. fu.nick_name as nickName,
  116. fu.username as userName,
  117. fu.avatar,
  118. fu.phone as phoneNumber,
  119. fu.create_time,
  120. max(fcwl.create_time) as watchDate
  121. from fs_user_course_video fucv
  122. inner join fs_course_watch_log fcwl on fcwl.video_id = fucv.video_id
  123. inner join fs_user fu on fu.user_id = fcwl.user_id
  124. where fucv.video_id = #{params.videoId} and fcwl.send_type = 1
  125. <if test="params.keyword != null and params.keyword != ''">
  126. and (
  127. fu.user_id = #{params.keyword}
  128. or fu.nick_name like concat('%', #{params.keyword}, '%')
  129. or fu.username like concat('%', #{params.keyword}, '%')
  130. or fu.phone = #{params.keyword}
  131. )
  132. </if>
  133. <if test="params.companyUserId != null">
  134. and fcwl.company_user_id = #{params.companyUserId}
  135. </if>
  136. <if test="params.periodId != null">
  137. and fcwl.period_id = #{params.periodId}
  138. </if>
  139. <if test="params.companyId != null">
  140. and fcwl.company_id = #{params.companyId}
  141. </if>
  142. <choose>
  143. <when test="params.type == 0">
  144. and (
  145. select count(log.log_id) as count
  146. from fs_course_answer_logs log
  147. where log.user_id = fu.user_id and log.video_id = fucv.video_id and log.is_right = 1
  148. <if test="params.periodId != null">
  149. and log.period_id = #{params.periodId}
  150. </if>
  151. ) > 0
  152. and (
  153. select count(log.log_id) as count
  154. from fs_course_red_packet_log log
  155. where log.user_id = fu.user_id and log.video_id = fucv.video_id and log.status = 1
  156. <if test="params.periodId != null">
  157. and log.period_id = #{params.periodId}
  158. </if>
  159. ) > 0
  160. </when>
  161. <when test="params.type == 1">
  162. and fcwl.log_type = 2
  163. </when>
  164. <when test="params.type == 2">
  165. and fcwl.log_type = 4
  166. </when>
  167. </choose>
  168. group by fu.user_id, fucv.video_id, fu.nick_name, fu.username, fu.avatar, fu.phone, fu.create_time
  169. order by watchDate desc
  170. </select>
  171. <select id="selectTodayCourseWatchLogCountByUserIdAndProjectId" resultType="java.lang.Integer">
  172. select count(distinct cwl.video_id)
  173. from fs_course_watch_log cwl
  174. inner join fs_user_course_video ucv on ucv.video_id = cwl.video_id
  175. inner join fs_user_course uc on uc.course_id = ucv.course_id
  176. where cwl.user_id = #{userId} and uc.project = #{projectId}
  177. and cwl.create_time between curdate() and date_add(curdate(), interval 1 day) and cwl.send_type = 1
  178. </select>
  179. <select id="selectCourseNamesByIds" resultType="java.util.Map">
  180. SELECT CAST(course_id AS SIGNED) AS courseId, course_name AS courseName
  181. FROM fs_user_course
  182. WHERE is_del = 0 AND course_id IN
  183. <foreach collection="courseIds" item="id" open="(" separator="," close=")">
  184. #{id}
  185. </foreach>
  186. </select>
  187. <insert id="insertFsUserCourse" parameterType="FsUserCourse" useGeneratedKeys="true" keyProperty="courseId">
  188. insert into fs_user_course
  189. <trim prefix="(" suffix=")" suffixOverrides=",">
  190. <if test="cateId != null">cate_id,</if>
  191. <if test="subCateId != null">sub_cate_id,</if>
  192. <if test="courseName != null">course_name,</if>
  193. <if test="title != null">title,</if>
  194. <if test="imgUrl != null">img_url,</if>
  195. <if test="sort != null">sort,</if>
  196. <if test="createTime != null">create_time,</if>
  197. <if test="updateTime != null">update_time,</if>
  198. <if test="status != null">status,</if>
  199. <if test="isVip != null">is_vip,</if>
  200. <if test="isHot != null">is_hot,</if>
  201. <if test="isShow != null">is_show,</if>
  202. <if test="views != null">views,</if>
  203. <if test="duration != null">duration,</if>
  204. <if test="description != null">description,</if>
  205. <if test="hotRanking != null">hot_ranking,</if>
  206. <if test="integral != null">integral,</if>
  207. <if test="price != null">price,</if>
  208. <if test="sellPrice != null">sell_price,</if>
  209. <if test="project != null">project,</if>
  210. <if test="tags != null">tags,</if>
  211. <if test="likes != null">likes,</if>
  212. <if test="favoriteNum != null">favorite_num,</if>
  213. <if test="shares != null">shares,</if>
  214. <if test="isAutoPlay != null">is_auto_play,</if>
  215. <if test="isFast != null">is_fast,</if>
  216. <if test="isBest != null">is_best,</if>
  217. <if test="isTui != null">is_tui,</if>
  218. <if test="hotNum != null">hot_num,</if>
  219. <if test="isIntegral != null">is_integral,</if>
  220. <if test="courseType != null">course_type,</if>
  221. <if test="talentId != null">talent_id,</if>
  222. <if test="isDel != null">is_del,</if>
  223. <if test="isNext != null">is_next,</if>
  224. <if test="isPrivate != null">is_private,</if>
  225. <if test="secondImg != null">second_img,</if>
  226. <if test="companyIds != null">company_ids,</if>
  227. <if test="userId != null">user_id,</if>
  228. <if test="configJson != null">config_json,</if>
  229. <if test="recHomeCourseTopEnabled != null">rec_home_course_top_enabled,</if>
  230. <if test="recHomeCourseTopMode != null">rec_home_course_top_mode,</if>
  231. <if test="recHomeCourseTopSort != null">rec_home_course_top_sort,</if>
  232. <if test="recMallHomeEnabled != null">rec_mall_home_enabled,</if>
  233. <if test="recMallHomeMode != null">rec_mall_home_mode,</if>
  234. <if test="recMallHomeSort != null">rec_mall_home_sort,</if>
  235. <if test="recHomeLongVideoEnabled != null">rec_home_long_video_enabled,</if>
  236. <if test="recHomeLongVideoMode != null">rec_home_long_video_mode,</if>
  237. <if test="recHomeLongVideoSort != null">rec_home_long_video_sort,</if>
  238. </trim>
  239. <trim prefix="values (" suffix=")" suffixOverrides=",">
  240. <if test="cateId != null">#{cateId},</if>
  241. <if test="subCateId != null">#{subCateId},</if>
  242. <if test="courseName != null">#{courseName},</if>
  243. <if test="title != null">#{title},</if>
  244. <if test="imgUrl != null">#{imgUrl},</if>
  245. <if test="sort != null">#{sort},</if>
  246. <if test="createTime != null">#{createTime},</if>
  247. <if test="updateTime != null">#{updateTime},</if>
  248. <if test="status != null">#{status},</if>
  249. <if test="isVip != null">#{isVip},</if>
  250. <if test="isHot != null">#{isHot},</if>
  251. <if test="isShow != null">#{isShow},</if>
  252. <if test="views != null">#{views},</if>
  253. <if test="duration != null">#{duration},</if>
  254. <if test="description != null">#{description},</if>
  255. <if test="hotRanking != null">#{hotRanking},</if>
  256. <if test="integral != null">#{integral},</if>
  257. <if test="price != null">#{price},</if>
  258. <if test="sellPrice != null">#{sellPrice},</if>
  259. <if test="project != null">#{project},</if>
  260. <if test="tags != null">#{tags},</if>
  261. <if test="likes != null">#{likes},</if>
  262. <if test="favoriteNum != null">#{favoriteNum},</if>
  263. <if test="shares != null">#{shares},</if>
  264. <if test="isAutoPlay != null">#{isAutoPlay},</if>
  265. <if test="isFast != null">#{isFast},</if>
  266. <if test="isBest != null">#{isBest},</if>
  267. <if test="isTui != null">#{isTui},</if>
  268. <if test="hotNum != null">#{hotNum},</if>
  269. <if test="isIntegral != null">#{isIntegral},</if>
  270. <if test="courseType != null">#{courseType},</if>
  271. <if test="talentId != null">#{talentId},</if>
  272. <if test="isDel != null">#{isDel},</if>
  273. <if test="isNext != null">#{isNext},</if>
  274. <if test="isPrivate != null">#{isPrivate},</if>
  275. <if test="secondImg != null">#{secondImg},</if>
  276. <if test="companyIds != null">#{companyIds},</if>
  277. <if test="userId != null">#{userId},</if>
  278. <if test="configJson != null">#{configJson},</if>
  279. <if test="recHomeCourseTopEnabled != null">#{recHomeCourseTopEnabled},</if>
  280. <if test="recHomeCourseTopMode != null">#{recHomeCourseTopMode},</if>
  281. <if test="recHomeCourseTopSort != null">#{recHomeCourseTopSort},</if>
  282. <if test="recMallHomeEnabled != null">#{recMallHomeEnabled},</if>
  283. <if test="recMallHomeMode != null">#{recMallHomeMode},</if>
  284. <if test="recMallHomeSort != null">#{recMallHomeSort},</if>
  285. <if test="recHomeLongVideoEnabled != null">#{recHomeLongVideoEnabled},</if>
  286. <if test="recHomeLongVideoMode != null">#{recHomeLongVideoMode},</if>
  287. <if test="recHomeLongVideoSort != null">#{recHomeLongVideoSort},</if>
  288. </trim>
  289. </insert>
  290. <update id="updateFsUserCourse" parameterType="FsUserCourse">
  291. update fs_user_course
  292. <trim prefix="SET" suffixOverrides=",">
  293. <if test="cateId != null">cate_id = #{cateId},</if>
  294. <if test="subCateId != null">sub_cate_id = #{subCateId},</if>
  295. <if test="courseName != null">course_name = #{courseName},</if>
  296. <if test="title != null">title = #{title},</if>
  297. <if test="imgUrl != null">img_url = #{imgUrl},</if>
  298. <if test="sort != null">sort = #{sort},</if>
  299. <if test="createTime != null">create_time = #{createTime},</if>
  300. <if test="updateTime != null">update_time = #{updateTime},</if>
  301. <if test="status != null">status = #{status},</if>
  302. <if test="isVip != null">is_vip = #{isVip},</if>
  303. <if test="isHot != null">is_hot = #{isHot},</if>
  304. <if test="isShow != null">is_show = #{isShow},</if>
  305. <if test="views != null">views = #{views},</if>
  306. <if test="duration != null">duration = #{duration},</if>
  307. <if test="description != null">description = #{description},</if>
  308. <if test="hotRanking != null">hot_ranking = #{hotRanking},</if>
  309. <if test="integral != null">integral = #{integral},</if>
  310. <if test="price != null">price = #{price},</if>
  311. <if test="sellPrice != null">sell_price = #{sellPrice},</if>
  312. <if test="project != null">project = #{project},</if>
  313. <if test="tags != null">tags = #{tags},</if>
  314. <if test="likes != null">likes = #{likes},</if>
  315. <if test="favoriteNum != null">favorite_num = #{favoriteNum},</if>
  316. <if test="shares != null">shares = #{shares},</if>
  317. <if test="isAutoPlay != null">is_auto_play = #{isAutoPlay},</if>
  318. <if test="isFast != null">is_fast = #{isFast},</if>
  319. <if test="isBest != null">is_best = #{isBest},</if>
  320. <if test="isTui != null">is_tui = #{isTui},</if>
  321. <if test="hotNum != null">hot_num = #{hotNum},</if>
  322. <if test="isIntegral != null">is_integral = #{isIntegral},</if>
  323. <if test="courseType != null">course_type = #{courseType},</if>
  324. <if test="talentId != null">talent_id = #{talentId},</if>
  325. <if test="isDel != null">is_del = #{isDel},</if>
  326. <if test="isNext != null">is_next = #{isNext},</if>
  327. <if test="isPrivate != null">is_private = #{isPrivate},</if>
  328. <if test="secondImg != null">second_img = #{secondImg},</if>
  329. <if test="companyIds != null">company_ids = #{companyIds},</if>
  330. <if test="configJson != null">config_json = #{configJson},</if>
  331. <if test="recHomeCourseTopEnabled != null">rec_home_course_top_enabled = #{recHomeCourseTopEnabled},</if>
  332. <if test="recHomeCourseTopMode != null">rec_home_course_top_mode = #{recHomeCourseTopMode},</if>
  333. <if test="recHomeCourseTopSort != null">rec_home_course_top_sort = #{recHomeCourseTopSort},</if>
  334. <if test="recMallHomeEnabled != null">rec_mall_home_enabled = #{recMallHomeEnabled},</if>
  335. <if test="recMallHomeMode != null">rec_mall_home_mode = #{recMallHomeMode},</if>
  336. <if test="recMallHomeSort != null">rec_mall_home_sort = #{recMallHomeSort},</if>
  337. <if test="recHomeLongVideoEnabled != null">rec_home_long_video_enabled = #{recHomeLongVideoEnabled},</if>
  338. <if test="recHomeLongVideoMode != null">rec_home_long_video_mode = #{recHomeLongVideoMode},</if>
  339. <if test="recHomeLongVideoSort != null">rec_home_long_video_sort = #{recHomeLongVideoSort},</if>
  340. </trim>
  341. where course_id = #{courseId}
  342. </update>
  343. <update id="deleteFsUserCourseByCourseId" parameterType="Long">
  344. update fs_user_course set is_del = 1 where course_id = #{courseId}
  345. </update>
  346. <update id="deleteFsUserCourseByCourseIds" parameterType="String">
  347. update fs_user_course set is_del = 1 where course_id in
  348. <foreach item="courseId" collection="array" open="(" separator="," close=")">
  349. #{courseId}
  350. </foreach>
  351. </update>
  352. <!-- <select id="getFsUserCourseList" resultType="com.fs.course.vo.newfs.FsUserCourseListVO">-->
  353. <!-- SELECT-->
  354. <!-- c.*,-->
  355. <!-- cc.cate_name,-->
  356. <!-- ucc.cate_name AS sub_cate_name-->
  357. <!-- FROM-->
  358. <!-- fs_user_course c-->
  359. <!-- LEFT JOIN fs_user_course_category cc ON c.cate_id = cc.cate_id-->
  360. <!-- LEFT JOIN fs_user_course_category ucc ON ucc.cate_id = c.sub_cate_id-->
  361. <!-- WHERE-->
  362. <!-- c.is_del = 0-->
  363. <!-- AND FIND_IN_SET(#{companyId}, c.company_ids)-->
  364. <!-- <if test="keyword != null and keyword !='' ">-->
  365. <!-- AND c.course_name LIKE concat('%',#{keyword},'%'-->
  366. <!-- )-->
  367. <!-- </if>-->
  368. <!-- ORDER BY-->
  369. <!-- c.course_id-->
  370. <!-- </select>-->
  371. <!-- 小程序公域课程列表:公域分类 + 非公域课 + 看课人数(去重 user_id, send_type=1) + 推荐位字段 -->
  372. <select id="selectFsUserCoursePublicAppList" resultType="com.fs.course.vo.FsUserCoursePublicAppVO">
  373. SELECT
  374. c.course_id AS courseId,
  375. COALESCE(c.title, c.course_name) AS courseTitle,
  376. c.course_name AS courseName,
  377. c.img_url AS imgUrl,
  378. c.second_img AS secondImg,
  379. IFNULL(wl_stat.watch_uv, 0) AS watchUserCount,
  380. IFNULL(c.rec_home_course_top_enabled, 0) AS recHomeCourseTopEnabled,
  381. c.rec_home_course_top_mode AS recHomeCourseTopMode,
  382. c.rec_home_course_top_sort AS recHomeCourseTopSort,
  383. IFNULL(c.rec_mall_home_enabled, 0) AS recMallHomeEnabled,
  384. c.rec_mall_home_mode AS recMallHomeMode,
  385. c.rec_mall_home_sort AS recMallHomeSort,
  386. IFNULL(c.rec_home_long_video_enabled, 0) AS recHomeLongVideoEnabled,
  387. c.rec_home_long_video_mode AS recHomeLongVideoMode,
  388. c.rec_home_long_video_sort AS recHomeLongVideoSort
  389. FROM fs_user_course c
  390. LEFT JOIN (
  391. SELECT course_id, COUNT(DISTINCT user_id) AS watch_uv
  392. FROM fs_course_watch_log
  393. WHERE send_type = 1
  394. GROUP BY course_id
  395. ) wl_stat ON wl_stat.course_id = c.course_id
  396. WHERE IFNULL(c.is_del, 0) = 0
  397. AND IFNULL(c.is_show, 0) = 1
  398. AND IFNULL(c.is_private, 0) = 0
  399. AND EXISTS (
  400. SELECT 1 FROM fs_user_course_category pc2
  401. WHERE pc2.cate_id = c.cate_id AND pc2.cate_type = 1 AND IFNULL(pc2.is_del, 0) = 0
  402. )
  403. AND (
  404. c.sub_cate_id IS NULL
  405. OR EXISTS (
  406. SELECT 1 FROM fs_user_course_category sc2
  407. WHERE sc2.cate_id = c.sub_cate_id AND sc2.cate_type = 1 AND IFNULL(sc2.is_del, 0) = 0
  408. )
  409. )
  410. <if test="q.cateId != null and q.subCateId != null">
  411. AND c.cate_id = #{q.cateId}
  412. AND c.sub_cate_id = #{q.subCateId}
  413. </if>
  414. <if test="q.subCateId != null and q.cateId == null">
  415. AND c.sub_cate_id = #{q.subCateId}
  416. </if>
  417. <if test="q.subCateId == null and q.cateId != null">
  418. AND (c.cate_id = #{q.cateId} OR c.sub_cate_id = #{q.cateId})
  419. </if>
  420. <if test="q.keyword != null and q.keyword != ''">
  421. AND (
  422. c.title LIKE CONCAT('%', #{q.keyword}, '%')
  423. OR c.course_name LIKE CONCAT('%', #{q.keyword}, '%')
  424. )
  425. </if>
  426. <if test="q.recommendSlot != null and q.recommendSlot == 1">
  427. AND IFNULL(c.rec_home_course_top_enabled, 0) = 1
  428. </if>
  429. <if test="q.recommendSlot != null and q.recommendSlot == 2">
  430. AND IFNULL(c.rec_mall_home_enabled, 0) = 1
  431. </if>
  432. <if test="q.recommendSlot != null and q.recommendSlot == 3">
  433. AND IFNULL(c.rec_home_long_video_enabled, 0) = 1
  434. </if>
  435. ORDER BY
  436. <if test="q.recommendSlot != null and q.recommendSlot == 1">
  437. IFNULL(c.rec_home_course_top_sort, 999999) ASC,
  438. </if>
  439. <if test="q.recommendSlot != null and q.recommendSlot == 2">
  440. IFNULL(c.rec_mall_home_sort, 999999) ASC,
  441. </if>
  442. <if test="q.recommendSlot != null and q.recommendSlot == 3">
  443. IFNULL(c.rec_home_long_video_sort, 999999) ASC,
  444. </if>
  445. c.sort ASC, c.course_id DESC
  446. </select>
  447. </mapper>