Files
video_server/src/main/resources/mapper/course/CourseDao.xml
2024-12-30 21:49:23 +08:00

274 lines
9.3 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sqx.modules.course.dao.CourseDao">
<update id="updateDelete">
update course
set is_delete=1
where course_id = #{id}
</update>
<select id="selectCourse" resultType="Map">
SELECT
c.classify_id as classifyId,
c.course_id as courseId,
c.course_label as courseLabel,
c.create_time createTime,
c.details,
c.img,
c.banner_img as bannerImg,
c.status,
c.is_delete as isDelete,
c.msg_type msgType,
c.msg_url as msgUrl,
c.pay_num as payNum,
c.price,
c.wholesale_price as wholesalePrice,
c.is_over as isOver,
c.title,
c.is_price as isPrice,
c.title_img as titleImg,
c.update_time as updateTime,
cc.classification_name as classificationName,
c.course_type as courseType,
c.banner_id as bannerId,
b.name as bannerName,
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,
round(10000*rand(),0) as goodNum,
ifnull(d.courseDetailsCount,0) as courseDetailsCount,
null AS courseDetailsName,
null AS courseDetailsId,
round(10000*rand(),0) as weekGoodNum,
0 as isRecommend
FROM
course AS c
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 (
SELECT
course_id,
COUNT(*) AS courseDetailsCount
FROM
course_details
GROUP BY
course_id
) AS d ON d.course_id = c.course_id
WHERE
1 = 1
AND c.is_delete = 0
<if test='null != wxShow and wxShow==1'>
and c.wx_show = #{wxShow}
</if>
<if test='null != wxShow and wxShow==2'>
and (c.wx_show = #{wxShow} or c.wx_show is null)
</if>
<if test='null != dyShow and dyShow==1'>
and c.dy_show = #{dyShow}
</if>
<if test='null != dyShow and dyShow==2'>
and (c.dy_show = #{dyShow} or c.dy_show is null)
</if>
<if test='null != title'>
and c.title LIKE CONCAT('%', #{title}, '%')
</if>
<if test='null!= classifyId and classifyId!=0'>
and c.classify_id = #{classifyId}
</if>
<if test='null!= bannerId and bannerId!=0'>
and c.banner_id = #{bannerId}
</if>
<if test="classifyId==0">
and c.is_recommend=1
</if>
<if test="over!=null">
and c.is_over=#{over}
</if>
<if test="isRecommend!=null and isRecommend!=-1">
and c.course_id in (select course_id from course_details where good=1)
</if>
<if test="status!=null and status!=0">
and c.status=#{status}
</if>
<if test="isPrice!=null">
and c.is_price=#{isPrice}
</if>
<if test="wxCourse!=null">
and c.wx_course_id is not null
</if>
<if test="dyCourse!=null">
and c.dy_status=4
</if>
<if test="sort==null">
order by c.sort asc,c.create_time desc
</if>
<if test="sort!=null and sort==1">
order by goodNum desc
</if>
<if test="sort!=null and sort==2">
order by weekGoodNum desc
</if>
</select>
<select id="selectCourseAdmin" resultType="Map">
SELECT
c.classify_id as classifyId,
c.course_id as courseId,
c.course_label as courseLabel,
c.course_label_ids as courseLabelIds,
c.create_time createTime,
c.details,
c.img,
c.banner_img as bannerImg,
c.status,
c.is_delete as isDelete,
c.msg_type msgType,
c.msg_url as msgUrl,
c.pay_num as payNum,
c.price,
c.wholesale_price as wholesalePrice,
c.is_over as isOver,
c.title,
c.is_price as isPrice,
c.title_img as titleImg,
c.update_time as updateTime,
cc.classification_name as classificationName,
c.course_type as courseType,
c.banner_id as bannerId,
b.name as bannerName,
ifnull(d.viewCounts,0) as viewCounts,
c.dy_img_id as dyImgId,
c.dy_course_id as dyCourseId,
c.dy_status as dyStatus,
c.dy_status_content as dyStatusContent,
c.dy_version as dyVersion,
c.license_num as licenseNum,
c.registration_num as registrationNum,
c.ordinary_record_num as ordinaryRecordNum,
c.key_record_num as keyRecordNum,
c.wx_course_id as wxCourseId,
c.wx_show as wxShow,
c.dy_show as dyShow,
c.sort,
c.`duration`,
c.`production_organisation` as productionOrganisation,
c.`director`,
c.`producer`,
c.`actor`,
c.`summary`,
c.`cost_distribution_uri` as costDistributionUri,
c.`assurance_uri` as assuranceUri,
c.`playlet_production_cost` as playletProductionCost,
c.`qualification_type` as qualificationType,
c.`registration_number` as registrationNumber,
c.`qualification_certificate_material_id` as qualificationCertificateMaterialId,
c.`cost_of_production` as costOfProduction,
c.`cost_commitment_letter_material_id` as costCommitmentLetterMaterialId,
c.`wx_course_status` as wxCourseStatus,
t.dyUrlStatus,
o.payMoney,
ifnull(d.goodNum,0) as goodNum,
ifnull(d.courseDetailsCount) as courseDetailsCount,
0 as weekGoodNum,
ifnull(tt.isRecommend,0) as isRecommend
FROM
course AS c
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 (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
1 = 1
AND c.is_delete = 0
<if test='null != wxShow and wxShow==1'>
and c.wx_show = #{wxShow}
</if>
<if test='null != wxShow and wxShow==2'>
and (c.wx_show = #{wxShow} or c.wx_show is null)
</if>
<if test='null != dyShow and dyShow==1'>
and c.dy_show = #{dyShow}
</if>
<if test='null != dyShow and dyShow==2'>
and (c.dy_show = #{dyShow} or c.dy_show is null)
</if>
<if test='null != title'>
and c.title LIKE CONCAT('%', #{title}, '%')
</if>
<if test='null!= classifyId and classifyId!=0'>
and c.classify_id = #{classifyId}
</if>
<if test='null!= bannerId and bannerId!=0'>
and c.banner_id = #{bannerId}
</if>
<if test="classifyId!=null and classifyId==0">
and c.is_recommend=1
</if>
<if test="over!=null and over==1">
and c.is_over=1
</if>
<if test="over!=null and over==2">
and (c.is_over is null or c.is_over=2)
</if>
<if test="isRecommend!=null and isRecommend!=-1">
and c.course_id in (select course_id from course_details where good=1)
</if>
<if test="status!=null and status!=0">
and c.status=#{status}
</if>
<if test="isPrice!=null">
and c.is_price=#{isPrice}
</if>
<if test="wxCourse!=null">
and c.wx_course_id is not null
</if>
<if test="dyCourse!=null">
and c.dy_status=4
</if>
<if test="sort==null">
order by c.sort asc,c.create_time desc
</if>
<if test="sort!=null and sort==1">
order by goodNum desc
</if>
<if test="sort!=null and sort==2">
order by weekGoodNum desc
</if>
</select>
<select id="selectCourseTitle" resultType="Map">
SELECT
c.classify_id as classifyId,
c.course_id as courseId,
c.course_label as courseLabel,
c.create_time createTime,
c.details,
c.img,
c.banner_img as bannerImg,
c.is_delete as isDelete,
c.msg_type msgType,
c.msg_url as msgUrl,
c.pay_num as payNum,
c.price,
c.wholesale_price as wholesalePrice,
c.status,
c.title,
c.title_img as titleImg,
c.update_time as updateTime
FROM
course c
WHERE
c.is_delete = 0 and c.status=1
<if test='null != title'>
and c.title LIKE #{title}
</if>
order by create_time desc
</select>
</mapper>