forked from kidgrow-microservices-platform

dougang
2021-04-08 6d0fee3cdc8cb213d0388ffa2e7ed7a091a1ea4c
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
<?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.kidgrow.oprationcenter.mapper.AdvisoryDoctorInfoMapper">
    <!--定义查询列-->
    <sql id="Column_List">
       *
    </sql>
 
    <!--sql查询片段-->
    <sql id="where">
        <where>
            <!--查询条件自行添加-->
            is_del =0
             <if test="p.id != null and p.id !=''">
                and id = #{p.id}
            </if>
             <if test="p.doctorId != null and p.doctorId !=''">
                and doctor_id = #{p.doctorId}
            </if>
            <if test="p.hospitalId != null and p.hospitalId !=''">
                and hospital_id = #{p.hospitalId}
            </if>
            <if test="p.service != null and p.service !=''">
                and service = #{p.service}
            </if>
            <if test="p.isDel != null and p.isDel !=''">
                and is_del = #{p.isDel}
            </if>
            <if test="p.excludeHospitalId != null and p.excludeHospitalId !=''">
                and hospital_id != #{p.excludeHospitalId}
            </if>
        </where>
    </sql>
 
       <!--列表使用-->
     <select id="findList" resultType="com.kidgrow.oprationcenter.model.AdvisoryDoctorInfo">
         SELECT
            a.*
        FROM
            advisory_doctor_info a
        WHERE
            a.is_del =0
            <if test="p.service != null and p.service != ''">
             and a.service = #{p.service}
            </if>
            <if test="p.hospitalName != null and p.hospitalName != ''">
             and a.hospital_name = #{p.hospitalName}
            </if>
            <if test="p.doctorName != null and p.doctorName != ''">
             and a.doctor_name like concat('%', #{p.doctorName}, '%')
            </if>
            order by a.create_time
    </select>
 
    <!--删除-->
    <update id="removeById" parameterType="java.lang.Long">
        update advisory_doctor_info set is_del=1 where id=#{id}
    </update>
 
    <!--定义根据-AdvisoryDoctorInfo当作查询条件返回对象-->
    <select id="findByObject" resultType="com.kidgrow.oprationcenter.model.AdvisoryDoctorInfo">
        select
        <include refid="Column_List"/>
        from advisory_doctor_info
        <include refid="where"/>
        order by id desc
    </select>
</mapper>