无关风月
2024-08-20 f237a61c412870933f47316a011237cd538de9bc
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?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.stylefeng.guns.modular.system.dao.CourseMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.Course">
        <id column="id" property="id" />
        <result column="courseName" property="courseName" />
        <result column="coverImg" property="coverImg" />
        <result column="introduce" property="introduce" />
        <result column="type" property="type" />
        <result column="difficulty" property="difficulty" />
        <result column="time" property="time" />
        <result column="isFree" property="isFree" />
        <result column="sort" property="sort" />
        <result column="state" property="state" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, courseName, coverImg, introduce, type, difficulty, time, isFree, sort, state
    </sql>
 
    <select id="courseSearch" resultType="com.stylefeng.guns.modular.system.vo.CourseList">
        select t1.id,t1.courseName,t1.allTime as `time`,t1.isFree,t1.difficulty,t1.coverImg,
        CONCAT(t3.name,'|',t2.name) as typeName,t2.appleAmount
        from t_course t1
        left join t_fitness_position t2 on t1.positionId = t2.id
        left join t_fitness_type t3 on t2.typeId = t3.id
        where t1.state = 1
        <if test="null != req.courseName and '' != req.courseName">
            and t1.courseName like CONCAT('%', #{req.courseName}, '%')
        </if>
        <if test="null != req.positionName and req.positionName.size()>0" >
            and t2.name in
            <foreach collection="req.positionName" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.time">
            and (t1.time between #{req.startTime} and #{req.endTime}
            <if test="null != req.startTime1">
                or t1.time between #{req.startTime1} and #{req.endTime1}
            </if>
            <if test="null != req.startTime2">
                or t1.time between #{req.startTime1} and #{req.endTime1}
            </if>
            )
        </if>
        <if test="null != req.courseIds and req.courseIds.size()>0" >
            and t1.id in
            <foreach collection="req.courseIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.typeIds and req.typeIds.size()>0" >
            and t3.id in
            <foreach collection="req.typeIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
 
        <if test="null != req.difficulty and req.difficulty.size()>0" >
            and t1.difficulty in
            <foreach collection="req.difficulty" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        order by t1.isFree desc , t1.sort desc
        limit #{req.pageNum}, #{req.pageSize}
    </select>
    <select id="courseSearch1" resultType="com.stylefeng.guns.modular.system.vo.CourseList">
        select t1.id,t1.courseName,t1.allTime as `time`,t1.isFree,t1.difficulty,t1.coverImg,t1.introduce,
        t2.amount as price,t2.appleAmount,
        CONCAT(t3.name,'|',t2.name) as typeName
        from t_course t1
        left join t_fitness_position t2 on t1.positionId = t2.id
        left join t_fitness_type t3 on t2.typeId = t3.id
        where t1.state = 1
        <if test="null != req.courseName and '' != req.courseName">
            and t1.courseName like CONCAT('%', #{req.courseName}, '%')
        </if>
        <if test="null != req.time">
            and (t1.time between #{req.startTime} and #{req.endTime}
            <if test="null != req.startTime1">
                or t1.time between #{req.startTime1} and #{req.endTime1}
            </if>
            <if test="null != req.startTime2">
                or t1.time between #{req.startTime1} and #{req.endTime1}
            </if>
            )
        </if>
        <if test="null != req.courseIds and req.courseIds.size()>0" >
            and t1.id in
            <foreach collection="req.courseIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.typeIds and req.typeIds.size()>0" >
            and t3.id in
            <foreach collection="req.typeIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.positionName and req.positionName.size()>0" >
            and t2.name in
            <foreach collection="req.positionName" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.difficulty and req.difficulty.size()>0" >
            and t1.difficulty in
            <foreach collection="req.difficulty" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        order by t1.isFree desc , t1.sort desc
 
    </select>
 
</mapper>