tj
2025-06-05 2d549a04870d1315868a7cf19952b64e8071e711
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
<?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.cloudroam.mapper.ContactInfoMapperCustom">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.cloudroam.model.ContactInfoDO">
        <id column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="delete_time" property="deleteTime" />
        <result column="tenant_id" property="tenantId" />
        <result column="company_id" property="companyId" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="phone" property="phone" />
        <result column="email_address" property="emailAddress" />
        <result column="title" property="title" />
        <result column="address" property="address" />
        <result column="remark" property="remark" />
        <result column="create_user_id" property="createUserId" />
        <result column="create_user_name" property="createUserName" />
        <result column="update_user_id" property="updateUserId" />
        <result column="update_user_name" property="updateUserName" />
        <result column="is_deleted" property="isDeleted" />
        <result column="delete_user_id" property="deleteUserId" />
        <result column="delete_user_name" property="deleteUserName" />
    </resultMap>
    <select id="getContactInfoPage" resultType="com.cloudroam.bo.ContactInfoBO">
 
        select * from (
            select c.*,
                i.`name` as company_name,
                sex.label as sex_name,
                project_list.project_list as project_list
            from contact_info c
            left join company_info i
            on c.company_id=i.id
            left join (
                select id,label,value from sys_dict_item where dict_type='sex' and is_deleted=0
            ) sex
            on c.sex=sex.`value`
            left join (
                select contact_id,GROUP_CONCAT(project_name) as project_list from project_info  group by contact_id
            )project_list
            on c.id=project_list.contact_id
        )t
        where t.is_deleted=0
        <if test=" keyword !=null and keyword !='' ">
            and (
            t.name like concat('%',#{keyword},'%')
            or t.sex_name like concat('%',#{keyword},'%')
            or t.phone like concat('%',#{keyword},'%')
            or t.company_name like concat('%',#{keyword},'%')
            or t.email_address like concat('%',#{keyword},'%')
            or t.address like concat('%',#{keyword},'%')
            or t.title like concat('%',#{keyword},'%')
            or t.remark like concat('%',#{keyword},'%')
            or t.project_list like concat('%',#{keyword},'%')
            )
        </if>
 
        order by create_time desc
 
    </select>
 
</mapper>