智慧保安后台管理-外网项目备份
zhongrj
2024-03-25 3222d83845148e2479af6aeb0f029def5f28f8b2
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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="org.springblade.modules.system.mapper.UserWxMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="userResultMap" type="org.springblade.modules.system.vo.UserVO">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="code" property="code"/>
        <result column="user_type" property="userType"/>
        <result column="account" property="account"/>
        <result column="password" property="password"/>
        <result column="name" property="name"/>
        <result column="real_name" property="realName"/>
        <result column="email" property="email"/>
        <result column="phone" property="phone"/>
        <result column="birthday" property="birthday"/>
        <result column="sex" property="sex"/>
        <result column="role_id" property="roleId"/>
        <result column="dept_id" property="deptId"/>
        <result column="post_id" property="postId"/>
        <result column="cardid" property="cardid"/>
        <result column="nativeplace" property="nativeplace"/>
        <result column="nation" property="nation"/>
        <result column="education" property="education"/>
        <result column="politicaloutlook" property="politicaloutlook"/>
        <result column="height" property="height"/>
        <result column="cell" property="cell"/>
        <result column="emails" property="emails"/>
        <result column="hold" property="hold"/>
        <result column="jurisdiction" property="jurisdiction"/>
        <result column="securitynumber" property="securitynumber"/>
        <result column="dispatch" property="dispatch"/>
        <result column="my_picture" property="myPicture"/>
        <result column="is_apply" property="isApply"/>
        <result column="is_apply" property="isApply"/>
        <result column="is_train" property="isTrain"/>
        <result column="birthtime" property="birthtime"/>
        <result column="healstats" property="healstats"/>
        <result column="soil" property="soil"/>
        <result column="reason_for_leav" property="reasonForLeav"/>
        <result column="accreditationStatus" property="accreditationStatus"/>
    </resultMap>
 
    <select id="getUserWx" resultType="org.springblade.modules.system.entity.UserWx">
        SELECT *
        FROM blade_user_wx
        WHERE tenant_id = #{param1}
          and account = #{param2}
          and password = #{param3}
          and is_deleted = 0
          and status = 1
    </select>
 
 
    <!--查询当前部门名称及父级部门名称-->
    <select id="getDeptName" resultType="java.lang.String">
            (select dept_name from blade_dept where id = #{deptId} and 1=1)
            union
            (
                select dept_name from blade_dept where id =  (select parent_id from blade_dept where id= #{deptId} and 1=1)
            )
    </select>
 
 
    <!--用户列表信息-->
    <select id="selectUserPage" resultMap="userResultMap">
        select bu.* from blade_user_wx bu
        left join blade_dept bd on bd.id = bu.dept_id
        left join sys_jurisdiction sj on sj.id = bu.jurisdiction
        left join blade_role br on br.id = bu.role_id
        where bu.is_deleted = 0 and bu.id != 1123598821738675201
        <if test="user.cardid != null and user.cardid !=''">
            and bu.cardid like concat('%', #{user.cardid},'%')
        </if>
        <if test="user.tenantId!=null and user.tenantId != ''">
            and tenant_id = #{user.tenantId}
        </if>
        <if test="user.account!=null and user.account != ''">
            and account like concat('%', #{user.account},'%')
        </if>
        <if test="user.isFreeze!=null">
            and bu.is_freeze = #{user.isFreeze}
        </if>
        <if test="user.roleId!=null and user.roleId != ''">
            and (br.role_alias = '公安管理员' or br.role_alias = '民警')
        </if>
        <if test="user.realName!=null and user.realName != ''">
            and real_name like concat(concat('%', #{user.realName}),'%')
        </if>
        <if test="user.deptId!=null and user.deptId != ''">
            and bd.id in
            (
            select id from blade_dept where id = #{user.deptId}
            union
            SELECT
            id
            FROM
            (
            SELECT
            t1.id,t1.parent_id,t1.dept_name,
            IF
            ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
            FROM
            ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
            ( SELECT @pids := #{user.deptId} ) t2
            ) t3
            WHERE
            ischild != 0
            )
        </if>
        <if test="user.userType!=null and user.userType != ''">
            and user_type = #{user.userType}
        </if>
        <if test="user.nativeplace!=null and user.nativeplace != ''">
            and nativeplace = #{user.nativeplace}
        </if>
        <if test="user.sex!=null and user.sex != ''">
            and sex = #{user.sex}
        </if>
        <if test="user.status!=null and user.status != ''">
            and status = #{user.status}
        </if>
        <if test="user.hold!=null and user.hold != ''">
            and hold = #{user.hold}
        </if>
        <if test="user.jurisdiction!=null and user.jurisdiction != '' and user.jurisdiction!='1372091709474910209'">
            and (sj.id = #{user.jurisdiction} or sj.parent_id = #{user.jurisdiction})
        </if>
        <if test="user.securitynumber!=null and user.securitynumber != ''">
            and securitynumber = #{user.securitynumber}
        </if>
        <if test="user.examinationType!=null and user.examinationType != ''">
            and examination_type = #{user.examinationType}
        </if>
        ORDER BY bu.id desc
    </select>
    <select id="getUserDetailById" resultType="org.springblade.modules.system.vo.UserVO">
        select bu.* from blade_user_wx bu
        where bu.is_deleted = 0
          and bu.id = #{id}
    </select>
    <select id="exportUser" resultType="org.springblade.modules.system.excel.UserWxExcel">
        SELECT
        bu.id,
        bd.dept_name AS deptId,
        bu.real_name,
        bu.phone,
        bu.cardid
        FROM
        blade_user_wx bu
        LEFT JOIN blade_dept bd ON bu.dept_id = bd.id
        where bu.is_deleted = 0
        <if test="obj.account != null and obj.account != ''">
            AND bu.account LIKE CONCAT('%',#{obj.account},'%')
        </if>
        <if test="obj.realName != null and obj.realName != ''">
            AND bu.real_name LIKE CONCAT('%',#{obj.realName},'%')
        </if>
        <if test="obj.deptId != null and obj.deptId != ''">
            AND bu.dept_id = #{obj.deptId}
        </if>
        <if test="obj.cardid != null and obj.cardid != ''">
            and bu.cardid like concat('%', #{obj.cardid},'%')
        </if>
        ORDER BY bu.id desc
    </select>
 
 
</mapper>