分库不支持子查询修改为关联查询
This commit is contained in:
parent
6f1e9e34df
commit
e5af376cae
|
|
@ -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,
|
||||||
(select count(*) from course_details d where d.course_id=c.course_id ) as courseDetailsCount,
|
d.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,
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
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
|
||||||
left join banner as b on b.id=c.banner_id
|
left join banner as b on b.id=c.banner_id
|
||||||
|
left join (select course_id,count(*) as courseDetailsCount from course_details group by course_id) d.course_id = c.course_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND c.is_delete = 0
|
AND c.is_delete = 0
|
||||||
|
|
@ -130,7 +131,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,
|
||||||
(select sum(cd.view_count) from course_details cd where cd.course_id = c.course_id ) as viewCounts,
|
d.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,
|
||||||
|
|
@ -153,24 +154,26 @@
|
||||||
c.`cost_distribution_uri` as costDistributionUri,
|
c.`cost_distribution_uri` as costDistributionUri,
|
||||||
c.`assurance_uri` as assuranceUri,
|
c.`assurance_uri` as assuranceUri,
|
||||||
c.`playlet_production_cost` as playletProductionCost,
|
c.`playlet_production_cost` as playletProductionCost,
|
||||||
|
|
||||||
c.`qualification_type` as qualificationType,
|
c.`qualification_type` as qualificationType,
|
||||||
c.`registration_number` as registrationNumber,
|
c.`registration_number` as registrationNumber,
|
||||||
c.`qualification_certificate_material_id` as qualificationCertificateMaterialId,
|
c.`qualification_certificate_material_id` as qualificationCertificateMaterialId,
|
||||||
c.`cost_of_production` as costOfProduction,
|
c.`cost_of_production` as costOfProduction,
|
||||||
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
|
||||||
c.`wx_course_status` as wxCourseStatus,
|
c.`wx_course_status` as wxCourseStatus,
|
||||||
|
t.dyUrlStatus,
|
||||||
(select count(*) from course_details where dy_url_status in (1,3) or dy_url_status=null) as dyUrlStatus,
|
o.payMoney,
|
||||||
(select sum(o.pay_money) from orders o where o.course_id=c.course_id and o.status=1) as payMoney,
|
d.goodNum,
|
||||||
(select sum(good_num) from course_details d where d.course_id=c.course_id ) as goodNum,
|
d.courseDetailsCount,
|
||||||
(select count(*) from course_details d where d.course_id=c.course_id ) as courseDetailsCount,
|
|
||||||
0 as weekGoodNum,
|
0 as weekGoodNum,
|
||||||
(select count(*) from course_details cd where c.course_id=cd.course_id and cd.good=1 ) as isRecommend
|
tt.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
|
||||||
left join banner as b on b.id=c.banner_id
|
left join banner as b on b.id=c.banner_id
|
||||||
|
left join (select 1 as id,count(*) as dyUrlStatus from course_details where dy_url_status in (1,3) or dy_url_status=null group by course_id) t on t.id = 1
|
||||||
|
left join (select course_id,sum(pay_money) as payMoney from orders where status=1 group by course_id) o on o.course_id = c.course_id
|
||||||
|
left join (select course_id,sum(view_count) as viewCounts,sum(good_num) as goodNum,count(*) as courseDetailsCount from course_details group by course_id) d on d.course_id = c.course_id
|
||||||
|
left join (select course_id,count(*) as isRecommend from course_details where good=1 group by course_id) tt on tt.course_id = c.course_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND c.is_delete = 0
|
AND c.is_delete = 0
|
||||||
|
|
@ -219,8 +222,6 @@
|
||||||
<if test="dyCourse!=null">
|
<if test="dyCourse!=null">
|
||||||
and c.dy_status=4
|
and c.dy_status=4
|
||||||
</if>
|
</if>
|
||||||
order by c.sort asc,c.create_time desc
|
|
||||||
<!--
|
|
||||||
<if test="sort==null">
|
<if test="sort==null">
|
||||||
order by c.sort asc,c.create_time desc
|
order by c.sort asc,c.create_time desc
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -230,7 +231,6 @@
|
||||||
<if test="sort!=null and sort==2">
|
<if test="sort!=null and sort==2">
|
||||||
order by weekGoodNum desc
|
order by weekGoodNum desc
|
||||||
</if>
|
</if>
|
||||||
-->
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCourseTitle" resultType="Map">
|
<select id="selectCourseTitle" resultType="Map">
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@
|
||||||
<!--查找指定短剧的目录 按照顺序数字升序-->
|
<!--查找指定短剧的目录 按照顺序数字升序-->
|
||||||
<select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="findByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
select c.*,
|
select c.*,
|
||||||
(select count(*) from course_collect cc where cc.user_id=#{userId} and cc.course_details_id=c.course_details_id and cc.classify=2) as isGood
|
cc.isGood
|
||||||
from course_details c where c.course_id=#{id} order by c.sort asc
|
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
|
||||||
|
where c.course_id=#{id} order by c.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectCoursePageByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="selectCoursePageByCourseId" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
|
|
@ -21,15 +23,23 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="findByCourseIdNotUrl" resultType="com.sqx.modules.course.entity.CourseDetails">
|
<select id="findByCourseIdNotUrl" resultType="com.sqx.modules.course.entity.CourseDetails">
|
||||||
select c.course_details_id as courseDetailsId,c.course_id as courseId,c.wx_course_details_id as wxCourseDetailsId,
|
select c.course_details_id as courseDetailsId,
|
||||||
c.course_details_name as courseDetailsName,c.create_time as createTime,
|
c.course_id as courseId,
|
||||||
c.title_img as titleImg,c.content,c.good_num as goodNum,c.price,
|
c.wx_course_details_id as wxCourseDetailsId,
|
||||||
|
c.course_details_name as courseDetailsName,
|
||||||
|
c.create_time as createTime,
|
||||||
|
c.title_img as titleImg,
|
||||||
|
c.content,
|
||||||
|
c.good_num as goodNum,
|
||||||
|
c.price,
|
||||||
if(c.is_price!=1,c.video_url,'') as videoUrl,
|
if(c.is_price!=1,c.video_url,'') as videoUrl,
|
||||||
c.dy_episode_id as dyEpisodeId,c.advertising,
|
c.dy_episode_id as dyEpisodeId,
|
||||||
|
c.advertising,
|
||||||
c.view_count as viewCount,
|
c.view_count as viewCount,
|
||||||
c.play_complete_count as playCompleteCount,
|
c.play_complete_count as playCompleteCount,
|
||||||
(select count(*) from course_collect cc where cc.user_id=#{userId} and cc.course_details_id=c.course_details_id and cc.classify=2) as isGood
|
cc.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
|
||||||
where c.course_id=#{id} order by c.sort asc
|
where c.course_id=#{id} order by c.sort asc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue