首页查询优化
This commit is contained in:
@@ -31,39 +31,19 @@
|
||||
c.course_type as courseType,
|
||||
c.banner_id as bannerId,
|
||||
b.name as bannerName,
|
||||
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
|
||||
0 as viewCounts,
|
||||
c.dy_img_id as dyImgId,
|
||||
c.dy_course_id as dyCourseId,
|
||||
c.wx_course_id as wxCourseId,
|
||||
c.wx_show as wxShow,
|
||||
c.dy_show as dyShow,
|
||||
c.sort,
|
||||
(select sum(good_num) from course_details d where d.course_id=c.course_id ) as goodNum,
|
||||
(select count(*) from course_details d where d.course_id=c.course_id ) as courseDetailsCount,
|
||||
<if test="userId!=null">
|
||||
(
|
||||
SELECT
|
||||
cc.course_details_id
|
||||
FROM
|
||||
course_collect cc
|
||||
WHERE
|
||||
cc.course_id = c.course_id
|
||||
AND cc.classify = 3
|
||||
and cc.user_id = #{userId}
|
||||
ORDER BY
|
||||
cc.update_time desc
|
||||
LIMIT 1
|
||||
) AS courseDetailsId,
|
||||
</if>
|
||||
<if test="userId==null">
|
||||
null AS courseDetailsName,
|
||||
null AS courseDetailsId,
|
||||
</if>
|
||||
|
||||
(select count(*) from course_collect d where d.course_id=c.course_id
|
||||
and date_format(create_time,'%Y-%m-%d')>=date_format(#{startTime},'%Y-%m-%d') and
|
||||
date_format(create_time,'%Y-%m-%d')<=date_format(#{endTime},'%Y-%m-%d') ) as weekGoodNum,
|
||||
(select count(*) from course_details cd where c.course_id=cd.course_id and cd.good=1 ) as isRecommend
|
||||
0 as goodNum,
|
||||
0 as courseDetailsCount,
|
||||
null AS courseDetailsName,
|
||||
null AS courseDetailsId,
|
||||
0 as weekGoodNum,
|
||||
0 as isRecommend
|
||||
FROM
|
||||
course AS c
|
||||
LEFT JOIN course_classification AS cc ON c.classify_id = cc.classification_id
|
||||
@@ -113,6 +93,8 @@
|
||||
<if test="dyCourse!=null">
|
||||
and c.dy_status=4
|
||||
</if>
|
||||
order by c.sort asc,c.create_time desc
|
||||
<!--
|
||||
<if test="sort==null">
|
||||
order by c.sort asc
|
||||
</if>
|
||||
@@ -122,6 +104,7 @@
|
||||
<if test="sort!=null and sort==2">
|
||||
order by weekGoodNum desc
|
||||
</if>
|
||||
-->
|
||||
</select>
|
||||
|
||||
<select id="selectCourseAdmin" resultType="Map">
|
||||
@@ -241,6 +224,8 @@
|
||||
<if test="dyCourse!=null">
|
||||
and c.dy_status=4
|
||||
</if>
|
||||
order by c.sort asc,c.create_time desc
|
||||
<!--
|
||||
<if test="sort==null">
|
||||
order by c.sort asc,c.create_time desc
|
||||
</if>
|
||||
@@ -250,6 +235,7 @@
|
||||
<if test="sort!=null and sort==2">
|
||||
order by weekGoodNum desc
|
||||
</if>
|
||||
-->
|
||||
</select>
|
||||
|
||||
<select id="selectCourseTitle" resultType="Map">
|
||||
|
||||
Reference in New Issue
Block a user