goupan
2024-04-17 812c482cd66e43a89d035dc7f2bf9c7f1cfd98b3
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="cn.stylefeng.guns.modular.business.mapper.MentalTestRecordMapper">
 
    <select id="myTestTopic" resultType="cn.stylefeng.guns.modular.business.dto.MentalTestMyTestTopicDTO">
        SELECT
            o.*,
            tt.status_flag topicStatus,
            tt.title,
            tt.class_id,
            tt.intro,
            tt.image,
            tt.test_type,
            tt.test_amount,
            tt.consult_one,
            tt.consult_amount,
            tt.test_people_num,
            tt.test_set_num
        FROM
            t_mental_test_record o
            LEFT JOIN t_mental_test_topic tt ON tt.id = o.topic_id
        <where>
            <if test="userId != null">
                AND o.user_id = #{userId}
            </if>
            <if test="topicId != null">
                AND o.topic_id = #{topicId}
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
    <select id="myTestRecordTopicByMentalAppointmentId" resultType="cn.stylefeng.guns.modular.business.dto.MentalTestMyTestTopicDTO">
        SELECT
            o.*,
            tt.status_flag topicStatus,
            tt.title,
            tt.class_id,
            tt.intro,
            tt.image,
            tt.test_type,
            tt.test_amount,
            tt.consult_one,
            tt.consult_amount,
            tt.test_people_num,
            tt.test_set_num
        FROM
            t_mental_test_record o
            LEFT JOIN t_mental_test_topic tt ON tt.id = o.topic_id
        <where>
            <if test="mentalAppointmentId != null">
                AND o.mental_appointment_id = #{mentalAppointmentId}
            </if>
            <if test="mentalAppointmentIdList != null">
                AND o.mental_appointment_id IN
                <foreach collection="mentalAppointmentIdList" item="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
    <select id="myTestOrder" resultType="cn.stylefeng.guns.modular.business.dto.MentalTestMyTestOrderDTO">
        SELECT
            o.*,
            tt.id topicId,
            tt.status_flag topicStatus,
            tt.title,
            tt.class_id,
            tt.intro,
            tt.image,
            tt.test_type,
            tt.test_amount,
            tt.consult_one,
            tt.consult_amount,
            tt.test_people_num,
            tt.test_set_num
        FROM
            t_order_mental_test o
            LEFT JOIN t_mental_test_topic tt ON tt.id = o.goods_id
        <where>
            AND o.status_flag = 1 AND ( ( tt.test_type = 0 AND o.test_flag = 1 ) OR tt.test_type = 1 OR o.is_back = 1 )
            <if test="userId != null">
                AND o.user_id = #{userId}
            </if>
            <if test="topicId != null">
                AND o.goods_id = #{topicId}
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
    <select id="getPage" resultType="cn.stylefeng.guns.modular.business.dto.MentalTestRecordPageDTO">
        SELECT
            tt.*,
            o.create_time,
            tu.nick_name,
            tu.telephone
        FROM
            t_mental_test_record o
                LEFT JOIN t_mental_test_topic tt ON tt.id = o.topic_id
                LEFT JOIN toc_customer tu ON tu.customer_id = o.user_id
        <where>
            <if test="title != null and title != ''">
                AND tt.title LIKE CONCAT('%', #{title}, '%')
            </if>
            <if test="testType != null">
                AND tt.test_type = #{testType}
            </if>
            <if test="nickName != null and nickName != ''">
                AND tu.nick_name LIKE CONCAT('%', #{nickName}, '%')
            </if>
            <if test="telephone != null and telephone != ''">
                AND tu.telephone LIKE CONCAT('%', #{telephone}, '%')
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
</mapper>