首页查询优化

This commit is contained in:
谭凯凯
2024-12-30 21:49:23 +08:00
committed by Tankaikai
parent 0aed96e92e
commit 7cb257317c
2 changed files with 9 additions and 8 deletions

View File

@@ -39,7 +39,7 @@
c.dy_show as dyShow, c.dy_show as dyShow,
c.sort, c.sort,
round(10000*rand(),0) as goodNum, round(10000*rand(),0) as goodNum,
d.courseDetailsCount, ifnull(d.courseDetailsCount,0) as courseDetailsCount,
null AS courseDetailsName, null AS courseDetailsName,
null AS courseDetailsId, null AS courseDetailsId,
round(10000*rand(),0) as weekGoodNum, round(10000*rand(),0) as weekGoodNum,
@@ -139,7 +139,7 @@
c.course_type as courseType, c.course_type as courseType,
c.banner_id as bannerId, c.banner_id as bannerId,
b.name as bannerName, b.name as bannerName,
d.viewCounts, ifnull(d.viewCounts,0) as viewCounts,
c.dy_img_id as dyImgId, c.dy_img_id as dyImgId,
c.dy_course_id as dyCourseId, c.dy_course_id as dyCourseId,
c.dy_status as dyStatus, c.dy_status as dyStatus,
@@ -170,10 +170,10 @@
c.`wx_course_status` as wxCourseStatus, c.`wx_course_status` as wxCourseStatus,
t.dyUrlStatus, t.dyUrlStatus,
o.payMoney, o.payMoney,
d.goodNum, ifnull(d.goodNum,0) as goodNum,
d.courseDetailsCount, ifnull(d.courseDetailsCount) as courseDetailsCount,
0 as weekGoodNum, 0 as weekGoodNum,
tt.isRecommend ifnull(tt.isRecommend,0) as isRecommend
FROM FROM
course AS c course AS c
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id

View File

@@ -4,8 +4,9 @@
<!--查找指定短剧的目录 按照顺序数字升序--> <!--查找指定短剧的目录 按照顺序数字升序-->
<select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails"> <select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
select c.*, select
cc.isGood c.*,
ifnull(cc.isGood,0) as isGood
from course_details c from course_details c
left join (select course_details_id,count(*) isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on c.course_details_id = c.course_details_id left join (select course_details_id,count(*) isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on c.course_details_id = c.course_details_id
where c.course_id=#{id} order by c.sort asc where c.course_id=#{id} order by c.sort asc
@@ -37,7 +38,7 @@
c.advertising, c.advertising,
c.view_count as viewCount, c.view_count as viewCount,
c.play_complete_count as playCompleteCount, c.play_complete_count as playCompleteCount,
cc.isGood ifnull(cc.isGood,0) as isGood
from course_details c from course_details c
left join (select course_details_id,count(*) as isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on cc.course_details_id = c.course_details_id left join (select course_details_id,count(*) as isGood from course_collect where user_id=#{userId} and classify=2 group by course_details_id) cc on cc.course_details_id = c.course_details_id
where c.course_id=#{id} order by c.sort asc where c.course_id=#{id} order by c.sort asc