mitao
2025-03-14 08f1b1f1804a8bd833d42f257908d80e88387b55
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
<?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.panzhihua.sangeshenbian.dao.SystemUserMapper">
 
    
    <select id="list" resultType="com.panzhihua.sangeshenbian.warpper.SystemUserListVo">
        select
            a.id,
            a.name,
            a.phone,
            IF(a.four_department_id is not null, e.`name`, IF(a.three_department_id is not null, d.`name`, IF(a.two_department_id is not null, c.`name`, b.`name`))) as departmentName,
            f.`name` as systemPostName,
            g.`name` as systemRoleName,
            a.account_level as accountLevel,
            CASE 
                WHEN a.account_level = 1 THEN '市'
                WHEN a.account_level = 2 THEN CONCAT('区县-', a.districts)
                WHEN a.account_level = 3 THEN CONCAT('街道-', a.districts, '-', a.street)
                WHEN a.account_level = 4 THEN CONCAT('社区-', a.districts, '-', a.street, '-', a.community)
                ELSE ''
            END as accountLevelStr,
            a.`status`
        from sgsb_system_user a
        left join sgsb_department b on (a.one_department_id = b.id)
        left join sgsb_department c on (a.two_department_id = c.id)
        left join sgsb_department d on (a.three_department_id = d.id)
        left join sgsb_department e on (a.four_department_id = e.id)
        left join sgsb_system_post f on (a.system_post_id = f.id)
        left join sgsb_system_role g on (a.system_role_id = g.id)
        where a.`status` != 3
        <if test="null != query.name and '' != query.name">
            and a.name like CONCAT('%', #{query.name}, '%')
        </if>
        <if test="null != query.phone and '' != query.phone">
            and a.phone like CONCAT('%', #{query.phone}, '%')
        </if>
        <if test="null != query.departmentId">
            and (a.one_department_id = #{query.departmentId} or a.two_department_id = #{query.departmentId} or a.three_department_id = #{query.departmentId} or a.four_department_id = #{query.departmentId})
        </if>
        <if test="null != query.systemRoleId">
            and a.system_role_id = #{query.systemRoleId}
        </if>
        <if test="null != user.accountLevel and 2 == user.accountLevel">
            and a.account_level >= #{user.accountLevel} and a.districts_code = #{user.districtsCode}
        </if>
        <if test="null != user.accountLevel and 3 == user.accountLevel">
            and a.account_level >= #{user.accountLevel} and a.street_id = #{user.streetId}
        </if>
        <if test="null != user.accountLevel and 4 == user.accountLevel">
            and a.account_level >= #{user.accountLevel} and a.community_id = #{user.communityId}
        </if>
        <if test="null != user.accountLevel and 5 == user.accountLevel">
            and a.id = 0
        </if>
        <if test="null != query.accountLevel">
            and a.account_level = #{query.accountLevel}
        </if>
        order by a.create_time desc
    </select>
    
    
    
    <select id="getRegion" resultType="com.panzhihua.sangeshenbian.model.vo.RegionVO">
        select region_code as id, region_name as name from bc_region where parent_id = #{pcode}
    </select>
    
    
    <select id="getStreet" resultType="com.panzhihua.sangeshenbian.model.vo.RegionVO">
        select CAST(street_id AS CHAR) as id, name as name from com_street where area_code = #{areaCode}
    </select>
    
    
    <select id="getCommunity" resultType="com.panzhihua.sangeshenbian.model.vo.RegionVO">
        select CAST(community_id AS CHAR) as id, name as name from com_act where street_id = #{streetId}
    </select>
    
</mapper>