中扬CRM客户关系管理系统
#
luxiaotao1123
2022-09-16 3be9948bd0756e545d27f3b69456f1840fd9febb
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
<?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.zy.crm.system.mapper.UserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.zy.crm.system.entity.User">
        <id column="id" property="id" />
        <result column="host_id" property="hostId" />
        <result column="role_id" property="roleId" />
        <result column="dept_id" property="deptId" />
        <result column="username" property="username" />
        <result column="mobile" property="mobile" />
        <result column="password" property="password" />
        <result column="avatar" property="avatar" />
        <result column="email" property="email" />
        <result column="sex" property="sex" />
        <result column="create_time" property="createTime" />
        <result column="status" property="status" />
 
    </resultMap>
 
    <select id="listByPage" resultMap="BaseResultMap">
        SELECT
        su.*
        FROM sys_user su
        LEFT JOIN sys_dept sd ON su.dept_id = sd.id
        WHERE 1=1
        AND (CHARINDEX(','+#{deptId}+',', ','+sd.path+',') > 0 OR sd.id = #{deptId})
        <if test="hostId != null and hostId != ''">
            and su.host_id = #{hostId}
        </if>
        <if test="username != null and username != ''">
            and su.username like concat('%',#{username},'%')
        </if>
        <if test="mobile != null and mobile != ''">
            and su.mobile like concat('%',#{mobile},'%')
        </if>
        ORDER BY su.create_time DESC
    </select>
 
</mapper>