“mitao”
2026-03-27 2f05b4e14515e0a7dd7e76e8bf0e40ec1d8ef8e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?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.tcm.training.admin.live.mapper.HealthCourseMapper">
 
    <sql id="HealthCourseSelect">
        SELECT
            c.id,
            c.title,
            c.level_category_id AS levelCategoryId,
            lc.name AS levelName,
            c.difficulty_category_id AS difficultyCategoryId,
            dc.name AS difficultyName,
            c.expert_id AS expertId,
            e.name AS expertName,
            e.avatar AS expertAvatar,
            c.sale_price AS salePrice,
            c.summary,
            c.target_users AS targetUsers,
            c.cover_img AS coverImg,
            c.banner_imgs AS bannerImgs,
            c.content,
            c.base_sales_count AS baseSalesCount,
            c.real_sales_count AS realSalesCount,
            c.learn_user_count AS learnUserCount,
            c.favorite_count AS favoriteCount,
            c.total_duration_seconds AS totalDurationSeconds,
            c.video_count AS videoCount,
            c.status,
            c.is_home_recommend AS isHomeRecommend,
            c.sort,
            c.created_at AS createdAt,
            c.updated_at AS updatedAt
        FROM tcm_health_course c
        LEFT JOIN tcm_live_course_category lc ON lc.id = c.level_category_id AND lc.deleted = 0
        LEFT JOIN tcm_live_course_category dc ON dc.id = c.difficulty_category_id AND dc.deleted = 0
        LEFT JOIN tcm_expert e ON e.id = c.expert_id AND e.deleted = 0
        WHERE c.deleted = 0
    </sql>
 
    <select id="selectCoursePage" resultType="com.tcm.training.admin.live.vo.HealthCourseListRow">
        <include refid="HealthCourseSelect"/>
        <if test="keyword != null and keyword.trim() != ''">
            AND c.title LIKE CONCAT('%', #{keyword}, '%')
        </if>
        <if test="levelCategoryId != null">
            AND c.level_category_id = #{levelCategoryId}
        </if>
        <if test="difficultyCategoryId != null">
            AND c.difficulty_category_id = #{difficultyCategoryId}
        </if>
        <if test="status != null">
            AND c.status = #{status}
        </if>
        ORDER BY c.sort ASC, c.id DESC
    </select>
 
    <select id="selectCourseList" resultType="com.tcm.training.admin.live.vo.HealthCourseListRow">
        <include refid="HealthCourseSelect"/>
        <if test="keyword != null and keyword.trim() != ''">
            AND c.title LIKE CONCAT('%', #{keyword}, '%')
        </if>
        <if test="levelCategoryId != null">
            AND c.level_category_id = #{levelCategoryId}
        </if>
        <if test="difficultyCategoryId != null">
            AND c.difficulty_category_id = #{difficultyCategoryId}
        </if>
        <if test="status != null">
            AND c.status = #{status}
        </if>
        ORDER BY c.sort ASC, c.id DESC
    </select>
 
    <select id="selectCourseDetail" resultType="com.tcm.training.admin.live.vo.HealthCourseDetailRow">
        <include refid="HealthCourseSelect"/>
        AND c.id = #{id}
    </select>
 
</mapper>