guohongjin
2024-05-15 5b7639f0bd9e056738ec15100ed0532e965c6cd5
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
<?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.MentalAppointmentMapper">
 
    <select id="myMentalAppointment" resultType="cn.stylefeng.guns.modular.business.dto.MentalTestMyMentalAppointmentDTO">
        SELECT
            o.*,
            wu.nick_name workerNickName
        FROM
            t_mental_appointment o
        LEFT JOIN toc_customer wu ON o.worker_id = wu.customer_id
        <where>
            o.`type` is null
            <if test="statusFlagList != null and statusFlagList.size != 0">
                AND o.status_flag IN
                <foreach item="item" collection="statusFlagList" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="userId != null">
                AND o.user_id = #{userId}
            </if>
            <if test="consultantName != null">
                AND wu.nick_name LIKE CONCAT('%', #{consultantName}, '%')
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
    <select id="mentalAnalysisTimeConfigSchedule" resultType="cn.stylefeng.guns.modular.business.dto.MentalAppointmentPageDTO">
        SELECT
            o.id,
            o.type,
            o.status_flag,
            o.appointment_day,
            o.begin_time_point,
            o.end_time_point,
            o.user_id user_id,
            o.user_name userNickName,
            o.phone userTelephone,
            wu.customer_id worker_id,
            wu.nick_name worker_nick_name,
            wu.telephone worker_telephone
        FROM
            t_mental_appointment o
            LEFT JOIN toc_customer wu ON o.worker_id = wu.customer_id
        <where>
            o.`type` is null AND o.is_delete = 0
            <if test="counsellingInfoId != null">
                AND o.worker_id = #{counsellingInfoId}
            </if>
            <if test="statusFlag != null">
                AND o.status_flag = #{statusFlag}
            </if>
            <if test="statusFlag == null and statusFlagList != null and statusFlagList.size != 0">
                AND o.status_flag IN
                <foreach item="item" collection="statusFlagList" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="searchBeginTime != null and searchBeginTime != ''">
                AND o.appointment_day <![CDATA[ >= ]]> #{searchBeginTime}
            </if>
            <if test="searchEndTime != null and searchEndTime != ''">
                AND o.appointment_day <![CDATA[ <= ]]> #{searchEndTime}
            </if>
            <if test="workerNickName != null and workerNickName != ''">
                AND wu.nick_name LIKE CONCAT( '%', #{workerNickName}, '%' )
            </if>
            <if test="userNickName != null and userNickName != ''">
                AND o.user_name LIKE CONCAT( '%', #{userNickName}, '%' )
            </if>
            <if test="userTelephone != null and userTelephone != ''">
                AND o.phone LIKE CONCAT( '%', #{userTelephone}, '%' )
            </if>
        </where>
        ORDER BY
            o.create_time DESC
    </select>
 
    <select id="userMentalAppointmentPage" resultType="cn.stylefeng.guns.modular.business.dto.UserMentalAppointmentPageResponseDTO">
        SELECT * FROM t_mental_appointment o
        LEFT JOIN toc_customer tw ON tw.customer_id = o.worker_id
        <where>
            o.`type` is null
            <if test="userId != null">
                AND o.user_id = #{userId}
            </if>
            <if test="userId != null">
                AND o.status_flag = #{statusFlag}
            </if>
            <if test="name != null and name != ''">
                AND tw.nick_name LIKE CONCAT('%',#{name},'%')
            </if>
            <if test="telephone != null and telephone != ''">
                AND tw.telephone LIKE CONCAT('%',#{telephone},'%')
            </if>
        </where>
        ORDER BY o.create_time DESC
    </select>
 
</mapper>