Administrator
2023-06-19 49588f5a462ae7425e7eb030438a35fd80c246fa
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<?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.gk.firework.Mapper.UserInfoMapper" >
  <resultMap id="BaseResultMap" type="com.gk.firework.Domain.UserInfo" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="password" property="password" jdbcType="VARCHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="mobile" property="mobile" jdbcType="VARCHAR" />
    <result column="company" property="company" jdbcType="VARCHAR" />
    <result column="department" property="department" jdbcType="VARCHAR" />
    <result column="job" property="job" jdbcType="VARCHAR" />
    <result column="createdby" property="createdby" jdbcType="VARCHAR" />
    <result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
    <result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
    <result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
    <result column="province" property="province" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="area" property="area" jdbcType="VARCHAR" />
    <result column="town" property="town" jdbcType="VARCHAR" />
    <result column="community" property="community" jdbcType="VARCHAR" />
    <result column="companyid" property="companyid" jdbcType="BIGINT" />
    <result column="status" property="status" jdbcType="TINYINT" />
    <result column="expiredate" property="expiredate" jdbcType="TIMESTAMP" />
    <result column="isdel" property="isdel" jdbcType="TINYINT" />
    <result column="issale" property="issale" jdbcType="TINYINT" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="deadline" property="deadline" jdbcType="TIMESTAMP" />
  </resultMap>
 
  <resultMap id="UserVo" type="com.gk.firework.Domain.Vo.UserVo" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="password" property="password" jdbcType="VARCHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="mobile" property="mobile" jdbcType="VARCHAR" />
    <result column="company" property="company" jdbcType="VARCHAR" />
    <result column="department" property="department" jdbcType="VARCHAR" />
    <result column="job" property="job" jdbcType="VARCHAR" />
    <result column="createdby" property="createdby" jdbcType="VARCHAR" />
    <result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
    <result column="lastmodifiedby" property="lastmodifiedby" jdbcType="VARCHAR" />
    <result column="lastmodifieddate" property="lastmodifieddate" jdbcType="TIMESTAMP" />
    <result column="province" property="province" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="area" property="area" jdbcType="VARCHAR" />
    <result column="town" property="town" jdbcType="VARCHAR" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="community" property="community" jdbcType="VARCHAR" />
    <result column="companyid" property="companyid" jdbcType="BIGINT" />
    <result column="companynumber" property="companynumber" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="TINYINT" />
    <result column="expiredate" property="expiredate" jdbcType="TIMESTAMP" />
    <result column="isdel" property="isdel" jdbcType="TINYINT" />
    <result column="issale" property="issale" jdbcType="TINYINT" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="deadline" property="deadline" jdbcType="TIMESTAMP" />
    <collection property="authorizationCodes"
                javaType="java.util.List"
                ofType="com.gk.firework.Domain.AuthorizationInfo"
                column="companynumber"
                select="selectAuth">
      <id column="auth_id" property="id" jdbcType="BIGINT" />
      <result column="enterprisenumber" property="enterprisenumber" jdbcType="VARCHAR" />
      <result column="authcode" property="authcode" jdbcType="VARCHAR" />
      <result column="authcodeprefix" property="authcodeprefix" jdbcType="VARCHAR" />
      <result column="contractcode" property="contractcode" jdbcType="VARCHAR" />
      <result column="createdat" property="createdat" jdbcType="TIMESTAMP" />
      <result column="createdby" property="createdby" jdbcType="VARCHAR" />
      <result column="safetysupervision" property="safetysupervision" jdbcType="VARCHAR" />
      <result column="flag" property="flag" jdbcType="TINYINT" />
      <result column="lasttime" property="lasttime" jdbcType="TIMESTAMP" />
      <result column="auth_status" property="status" jdbcType="TINYINT" />
    </collection>
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, username, password, email, phone, mobile, company, department, job, createdby,
    createddate, lastmodifiedby, lastmodifieddate, province, city, area, town, community,
    companyid, status, expiredate, isdel, issale,type
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    <!--          -->
    select
    <include refid="Base_Column_List" />
    from user
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    <!--          -->
    delete from user
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteOneByCompanyId" parameterType="java.lang.Long">
    update user
    set isdel = 1
    where companyid = #{companyId}
  </delete>
  <update id="updateByPrimaryKeySelective" parameterType="com.gk.firework.Domain.UserInfo" >
    <!--          -->
    update user
    <set >
      <if test="username != null" >
        username = #{username,jdbcType=VARCHAR},
      </if>
      <if test="password != null" >
        password = #{password,jdbcType=VARCHAR},
      </if>
      <if test="email != null" >
        email = #{email,jdbcType=VARCHAR},
      </if>
      <if test="phone != null" >
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="mobile != null" >
        mobile = #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="company != null" >
        company = #{company,jdbcType=VARCHAR},
      </if>
      <if test="department != null" >
        department = #{department,jdbcType=VARCHAR},
      </if>
      <if test="job != null" >
        job = #{job,jdbcType=VARCHAR},
      </if>
      <if test="createdby != null" >
        createdby = #{createdby,jdbcType=VARCHAR},
      </if>
      <if test="createddate != null" >
        createddate = #{createddate,jdbcType=TIMESTAMP},
      </if>
      <if test="lastmodifiedby != null" >
        lastmodifiedby = #{lastmodifiedby,jdbcType=VARCHAR},
      </if>
      <if test="lastmodifieddate != null" >
        lastmodifieddate = #{lastmodifieddate,jdbcType=TIMESTAMP},
      </if>
      <if test="province != null" >
        province = #{province,jdbcType=VARCHAR},
      </if>
      <if test="city != null" >
        city = #{city,jdbcType=VARCHAR},
      </if>
      <if test="area != null" >
        area = #{area,jdbcType=VARCHAR},
      </if>
      <if test="town != null" >
        town = #{town,jdbcType=VARCHAR},
      </if>
      <if test="community != null" >
        community = #{community,jdbcType=VARCHAR},
      </if>
      <if test="companyid != null" >
        companyid = #{companyid,jdbcType=BIGINT},
      </if>
      <if test="companynumber != null" >
        #{companynumber,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="expiredate != null" >
        expiredate = #{expiredate,jdbcType=TIMESTAMP},
      </if>
      <if test="isdel != null" >
        isdel = #{isdel,jdbcType=TINYINT},
      </if>
      <if test="issale != null" >
        issale = #{issale,jdbcType=TINYINT},
      </if>
      <if test="type != null">
        type = #{type,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gk.firework.Domain.UserInfo" >
    <!--          -->
    update user
    set username = #{username,jdbcType=VARCHAR},
      password = #{password,jdbcType=VARCHAR},
      email = #{email,jdbcType=VARCHAR},
      phone = #{phone,jdbcType=VARCHAR},
      mobile = #{mobile,jdbcType=VARCHAR},
      company = #{company,jdbcType=VARCHAR},
      department = #{department,jdbcType=VARCHAR},
      job = #{job,jdbcType=VARCHAR},
      createdby = #{createdby,jdbcType=VARCHAR},
      createddate = #{createddate,jdbcType=TIMESTAMP},
      lastmodifiedby = #{lastmodifiedby,jdbcType=VARCHAR},
      lastmodifieddate = #{lastmodifieddate,jdbcType=TIMESTAMP},
      province = #{province,jdbcType=VARCHAR},
      city = #{city,jdbcType=VARCHAR},
      area = #{area,jdbcType=VARCHAR},
      town = #{town,jdbcType=VARCHAR},
      community = #{community,jdbcType=VARCHAR},
      companyid = #{companyid,jdbcType=BIGINT},
      status = #{status,jdbcType=TINYINT},
      expiredate = #{expiredate,jdbcType=TIMESTAMP},
      isdel = #{isdel,jdbcType=TINYINT},
      issale = #{issale,jdbcType=TINYINT},
      type  = #{type,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateDeadlineByCompanyId">
        update user
        set deadline = #{deadline}
        where companyid = #{companyid}
        and isdel = 0
 
  </update>
  <update id="updateDeadline2NullByComapnyId">
     update user
        set deadline = null
        where companyid = #{companyid}
        and isdel = 0
  </update>
  <select id="selectByLoginname" resultType="com.gk.firework.Domain.Vo.UserVo" parameterType="java.lang.String">
    select
     id, username, password, email, phone, mobile, company, department, job,province, city, area, town,
     community,companyid, status, expiredate, issale,type
    from user
    where username = #{username,jdbcType=VARCHAR}
    and isdel = 0
  </select>
  <select id="selectRoleByUser" resultType="com.gk.firework.Config.Oauth2.OauthRole">
    SELECT
    ar.id,
    ar.NAME,
    ar.code,
    ar.btnaccess
    FROM
    userroles AS aur
    LEFT JOIN role AS ar ON ar.id = aur.roleid
    WHERE
    aur.userid = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectUserDataGrid" resultMap="UserVo">
    select
    user.id,
    user.username,
    user.password,
    user.email,
    user.phone,
    user.mobile,
    user.company,
    user.department,
    user.job,
    user.province,
    user.city,
    user.area,
    user.town,
    user.code,
    user.community,
    user.companyid,
    user.status,
    user.expiredate,
    user.issale,
    user.type,
    user.lastmodifiedby,
    user.lastmodifieddate,
    user.companynumber,
    user.deadline,
    enterprise.safetysupervision safetysupervision
    from user as user
    left join enterprise as enterprise on user.companyid = enterprise.id
    <where>
      user.isdel = 0
      and user.issale = #{record.issale}
      <if test="record.username != null and record.username !=''">
       and user.username = #{record.username,jdbcType=VARCHAR}
      </if>
      <if test="record.company != null and record.company !=''">
        and user.company like concat ('%',#{record.company,jdbcType=VARCHAR},'%')
      </if>
      <if test="record.department != null and record.department !=''">
        and user.department like concat ('%',#{record.department,jdbcType=VARCHAR},'%')
      </if>
      <if test="record.job != null and record.job !=''">
        and user.job like concat ('%',#{record.job,jdbcType=VARCHAR},'%')
      </if>
      <if test="record.iscompany == 0">
        and user.companyid is null
      </if>
      <if test="record.iscompany == 1">
        and user.companyid is not null
      </if>
      <if test="record.type != 1">
        and user.type != 1
      </if>
      <if test="record.companyid != null">
        and user.companyid = #{record.companyid}
      </if>
      <if test="record.province != null and record.province !=''">
        and user.province = #{record.province,jdbcType=VARCHAR}
      </if>
      <if test="record.city != null and record.city !=''">
        and user.city = #{record.city,jdbcType=VARCHAR}
      </if>
      <if test="record.area != null and record.area !=''">
        and user.area = #{record.area,jdbcType=VARCHAR}
      </if>
      <if test="record.town != null and record.town !=''">
        and user.town = #{record.town,jdbcType=VARCHAR}
      </if>
      <if test="record.community != null and record.community !=''">
        and user.community = #{record.community,jdbcType=VARCHAR}
      </if>
 
      <if test="record.provinceSee != null and record.provinceSee !=''">
        and user.province = #{record.provinceSee,jdbcType=VARCHAR}
      </if>
      <if test="record.citySee != null and record.citySee !=''">
        and user.city = #{record.citySee,jdbcType=VARCHAR}
      </if>
      <if test="record.areaSee != null and record.areaSee !=''">
        and user.area = #{record.areaSee,jdbcType=VARCHAR}
      </if>
      <if test="record.townSee != null and record.townSee !=''">
        and user.town = #{record.townSee,jdbcType=VARCHAR}
      </if>
      <if test="record.communitySee != null and record.communitySee !=''">
        and user.community = #{record.communitySee,jdbcType=VARCHAR}
      </if>
      <if test="record.safetysupervision != null and record.safetysupervision !=''">
        and enterprise.safetysupervision = #{record.safetysupervision}
      </if>
 
    </where>
  </select>
 
  <select id="selectAuth"  resultType="com.gk.firework.Domain.AuthorizationInfo">
    select  *
    from authorization
    where enterprisenumber = #{companynumber}
  </select>
 
  <select id="selectUserInfo" resultType="com.gk.firework.Domain.UserInfo">
    select *
    from user
    <where>
      1=1
      and isdel = 0
      <if test="id != null">
        and id != #{id}
      </if>
      <if test="username != null and username !=''">
        and username = #{username}
      </if>
    </where>
  </select>
  <select id="getOneByCompanyId" resultType="com.gk.firework.Domain.UserInfo" parameterType="java.lang.Long">
    select *
    from user
    where  isdel = 0
    and companyid = #{companyId}
  </select>
  <select id="selectSupervise" resultType="com.gk.firework.Domain.UserInfo">
    select *
    from user
    <where>
      isdel = 0
      and companyid is null
      and status is null
      and issale = 0
      <if test="province != null and province != ''">
        and province = #{province}
      </if>
      <if test="city != null and city != ''">
        and city = #{city}
      </if>
      <if test="area != null and area !=''">
        and area = #{area}
      </if>
      <if test="town != null and town !=''">
        and town = #{town}
      </if>
      <if test="community != null and community !=''">
        and community = #{community}
      </if>
    </where>
    limit 1
  </select>
  <select id="selectUserVoByName" resultType="com.gk.firework.Domain.Vo.UserVo">
    select
    `user`. id,
    `user`.username,
    `user`.`password`,
    `user`.email,
    `user`.phone,
    `user`.mobile,
    `user`.company,
    `user`.department,
    `user`.job,
    `user`.province,
    `user`.city,
    `user`.area,
    `user`.town,
    `user`.community,
    `user`.companyid,
    `user`.`status`,
    `user`.expiredate,
    `user`.issale,
    `user`.`type`,
    `user`.companynumber,
    `user`.deadline,
    enterprise.safetysupervision as roleType
    from `user`
    left join enterprise on enterprise.enterprisenumber = `user`.companynumber
    where username = #{username,jdbcType=VARCHAR}
    and isdel = 0
  </select>
</mapper>