MasterUsers.xml 15.5 KB
   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
<?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.lyms.platform.permission.dao.master.MasterUsersMapper">

<resultMap id="UsersResultMap" type="com.lyms.platform.permission.model.Users">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="logincenter_id" property="logincenterId" jdbcType="INTEGER"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="org_id" property="orgId" jdbcType="INTEGER"/>
<result column="dept_id" property="deptId" jdbcType="INTEGER"/>
<result column="ks_id" property="ksId" jdbcType="INTEGER"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="account" property="account" jdbcType="VARCHAR"/>
<result column="pwd" property="pwd" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="publish_id" property="publishId" jdbcType="INTEGER"/>
<result column="publish_name" property="publishName" jdbcType="VARCHAR"/>
<result column="yn" property="yn" jdbcType="INTEGER"/>
<result column="enable" property="enable" jdbcType="INTEGER"/>
<result column="modified" property="modified" jdbcType="TIMESTAMP"/>
<result column="created" property="created" jdbcType="TIMESTAMP"/>
<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
<result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP"/>
<result column="foreign_id" property="foreignId" jdbcType="VARCHAR"/>
<result column="employee_id" property="employeeId" jdbcType="VARCHAR"/>
<result column="other_account" property="otherAccount" jdbcType="INTEGER"/>
<result column="zhiChenId" property="zhiChenId" jdbcType="INTEGER"/>
<result column="defaultpage" property="defaultPage" jdbcType="INTEGER"/>
</resultMap>

<insert id="addUsers" parameterType="com.lyms.platform.permission.model.Users">
<selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">SELECT LAST_INSERT_ID()</selectKey>
insert into users
(foreign_id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time,ks_id,zhiChenId,defaultpage

<if test="id != null and id >= 0">
,id
</if>
)
values
(#{foreignId},#{logincenterId},#{type},#{orgId},#{deptId},#{name},#{account},#{pwd},#{phone},#{publishId},#{publishName},#{yn},#{enable},#{modified},#{created},#{remarks},#{lastLoginTime},#{ksId},#{zhiChenId},#{defaultPage}
<if test="id != null and id >= 0">
,#{id}
</if>
)
</insert>


<update id="updateUsers" parameterType="com.lyms.platform.permission.model.Users">
update users
<set>
<if test="zhiChenId != null and zhiChenId >= 0">
zhiChenId = #{zhiChenId,jdbcType=INTEGER},
</if>
<if test="logincenterId != null and logincenterId >= 0">
logincenter_id = #{logincenterId,jdbcType=INTEGER},
</if>
<if test="type != null and type >= 0">
type = #{type,jdbcType=INTEGER},
</if>
<if test="orgId != null and orgId >= 0">
org_id = #{orgId,jdbcType=INTEGER},
</if>
<if test="deptId != null and deptId >= 0">
dept_id = #{deptId,jdbcType=INTEGER},
</if>
<if test="ksId != null and ksId >= 0">
ks_id = #{ksId,jdbcType=INTEGER},
</if>
<if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="foreignId != null and foreignId != ''">
foreign_id = #{foreignId,jdbcType=VARCHAR},
</if>
<if test="account != null">
account = #{account,jdbcType=VARCHAR},
</if>
<if test="pwd != null and pwd != ''">
pwd = #{pwd,jdbcType=VARCHAR},
</if>
<if test="phone != null ">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="publishId != null and publishId >= 0">
publish_id = #{publishId,jdbcType=INTEGER},
</if>
<if test="publishName != null and publishName != ''">
publish_name = #{publishName,jdbcType=VARCHAR},
</if>
<if test="yn != null and yn >= 0">
yn = #{yn,jdbcType=INTEGER},
</if>
<if test="enable != null and enable >= 0">
enable = #{enable,jdbcType=INTEGER},
</if>
<if test="modified != null">
modified = #{modified,jdbcType=TIMESTAMP},
</if>
<if test="created != null">
created = #{created,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null ">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="zhiChenId !=null">
zhiChenId =#{zhiChenId,jdbcType=VARCHAR},
</if>
<if test="defaultPage !=null">
defaultpage=#{defaultPage,jdbcType=VARCHAR}
</if>

</set>
where id = #{id,jdbcType=INTEGER}
</update>


<delete id="deleteUsers" parameterType="java.lang.Integer">
delete from users where id = #{id,jdbcType=INTEGER}
</delete>


<select id="getUsers" resultMap="UsersResultMap" parameterType="java.lang.Integer">
select id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time, ks_id,foreign_id,other_account,zhiChenId,defaultpage
from users where id = #{id,jdbcType=INTEGER}
</select>

<select id="getUsersByLoginCenterId" resultMap="UsersResultMap" parameterType="java.lang.Integer">
select id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time, ks_id,foreign_id,other_account,zhiChenId,defaultpage
from users where logincenter_id = #{id,jdbcType=INTEGER} and enable =1 order by last_login_time desc
</select>


<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>


<sql id="UsersCondition">
<where>
1 = 1
<if test="id != null and id >= 0">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="ids != null and ids.size() !=0 ">
AND id IN
<foreach collection="ids" item="title"
index="index" open="(" close=")" separator=",">
#{title}
</foreach>
</if>
<if test="logincenterId != null and logincenterId >= 0">
and logincenter_id = #{logincenterId,jdbcType=INTEGER}
</if>
<if test="type != null and type >= 0">
and type = #{type,jdbcType=INTEGER}
</if>
<if test="orgId != null and orgId >= 0">
and org_id = #{orgId,jdbcType=INTEGER}
</if>
<if test="deptId != null and deptId >= 0">
and dept_id = #{deptId,jdbcType=INTEGER}
</if>
<if test="ksId != null and ksId >= 0">
and ks_id = #{ksId,jdbcType=INTEGER}
</if>
<if test="name != null and name != ''">
and name = #{name,jdbcType=VARCHAR}
</if>
<if test="foreignId != null and foreignId != ''">
and foreign_id = #{foreignId,jdbcType=VARCHAR}
</if>
<if test="account != null and account != ''">
and account = #{account,jdbcType=VARCHAR}
</if>
<if test="pwd != null and pwd != ''">
and pwd = #{pwd,jdbcType=VARCHAR}
</if>
<if test="phone != null and phone != ''">
and phone = #{phone,jdbcType=VARCHAR}
</if>
<if test="publishId != null and publishId >= 0">
and publish_id = #{publishId,jdbcType=INTEGER}
</if>
<if test="publishName != null and publishName != ''">
and publish_name = #{publishName,jdbcType=VARCHAR}
</if>
<if test="yn != null and yn >= 0">
and yn = #{yn,jdbcType=INTEGER}
</if>
<if test="enable != null and enable >= 0">
and enable = #{enable,jdbcType=INTEGER}
</if>
<if test="modified != null">
and modified = #{modified,jdbcType=TIMESTAMP}
</if>
<if test="created != null">
and created = #{created,jdbcType=TIMESTAMP}
</if>
<if test="gteModified != null">
and modified >= #{gteModified,jdbcType=TIMESTAMP}
</if>
<if test="gteCreated != null">
and created >= #{gteCreated,jdbcType=TIMESTAMP}
</if>

<if test="remarks != null and remarks != ''">
and remarks = #{remarks,jdbcType=VARCHAR}
</if>
<if test="zhichenIds != null and zhichenIds.size() !=0 ">
AND zhiChenId IN
<foreach collection="zhichenIds" item="title"
index="index" open="(" close=")" separator=",">
#{title}
</foreach>
</if>


<if test="names != null and names.size() !=0 ">
AND name IN
<foreach collection="names" item="name"
index="index" open="(" close=")" separator=",">
#{name}
</foreach>
</if>

<if test="lastLoginTime != null">
and last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP}
</if>
<if test="otherAccount != null and otherAccount >= 0">
and other_account = #{otherAccount,jdbcType=INTEGER}
</if>
</where>
</sql>


<select id="queryUsers" resultMap="UsersResultMap" parameterType="com.lyms.platform.permission.model.UsersQuery">
select
id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,yn,enable,modified,created,remarks,last_login_time,
ks_id,foreign_id,other_account,zhiChenId,defaultpage
from users
<include refid="UsersCondition"/>
<include refid="orderAndLimit"/>
</select>


<select id="queryUsers2" resultMap="UsersResultMap" parameterType="com.lyms.platform.permission.model.UsersQuery">
select DISTINCT u.id
id,logincenter_id,type,org_id,dept_id,name,account,pwd,phone,publish_id,publish_name,u.yn,enable,modified,created,remarks,last_login_time,
ks_id,foreign_id,other_account,zhiChenId,defaultpage
from users u LEFT JOIN user_role_maps ur
on u.id = ur.user_id
where 1=1
<if test="keyword != null and keyword != ''">
and name like CONCAT(#{keyword}, '%')
</if>
<if test="ksId != null">
and u.ks_id = #{ksId,jdbcType=INTEGER}
</if>
<if test="orgIds != null and orgIds.size() > 0">
and u.org_id in
<foreach collection="orgIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="orgId != null">
and u.org_id = #{orgId,jdbcType=INTEGER}
</if>

<if test="deptId != null">
and u.dept_id = #{deptId,jdbcType=INTEGER}
</if>
<if test="roleId != null">
and ur.role_id = #{roleId,jdbcType=INTEGER}
</if>
<if test="yn != null">
and u.yn = #{yn,jdbcType=INTEGER}
</if>
<if test="type != null">
and u.type = #{type,jdbcType=INTEGER}
</if>
<if test="otherAccount != null">
and u.other_account = #{otherAccount,jdbcType=INTEGER}
</if>
<include refid="orderAndLimit"/>
</select>


<select id="queryUsersCount2" resultType="int" parameterType="com.lyms.platform.permission.model.UsersQuery">
select count(DISTINCT u.id)
from users u LEFT JOIN user_role_maps ur
on u.id = ur.user_id
where 1=1
<if test="keyword != null and keyword != ''">
and name like CONCAT(#{keyword}, '%')
</if>
<if test="ksId != null and ksId != ''">
and u.ks_id = #{ksId,jdbcType=INTEGER}
</if>
<if test="orgIds != null and orgIds.size() > 0">
and u.org_id in
<foreach collection="orgIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="deptId != null and deptId != ''">
and u.dept_id = #{deptId,jdbcType=INTEGER}
</if>
<if test="roleId != null and roleId != ''">
and ur.role_id = #{roleId,jdbcType=INTEGER}
</if>
<if test="yn != null and yn != ''">
and u.yn = #{yn,jdbcType=INTEGER}
</if>
<if test="type != null ">
and u.type = #{type,jdbcType=INTEGER}
</if>
<if test="otherAccount != null">
and u.other_account = #{otherAccount,jdbcType=INTEGER}
</if>
</select>


<select id="queryUsersCount" resultType="int" parameterType="com.lyms.platform.permission.model.UsersQuery">
select count(1) from users
<include refid="UsersCondition"/>
</select>


<insert id="addUserScore" parameterType="com.lyms.platform.permission.model.UserScore">
insert into lyms_user_score
(user_id,course_id,patient_course_id,score,created)
values
(#{userId},#{courseId},#{patientCourseId},#{score},#{created})
</insert>

<select id="findUserAvgScore" parameterType="java.lang.Integer" resultType="java.lang.Integer">
SELECT avg(score) as score from lyms_user_score
WHERE user_id=#{userId}
</select>

<select id="getUserId" resultType="java.lang.Integer">
select id from users where org_id=#{orgId} and name=#{doctorName}

</select>

<update id="updateSeq" parameterType="String" >
update baby_seq set seq = seq+1 where year = #{yearStr}
</update>
<select id="getBabySeq" resultType="long" parameterType="String">
select seq from baby_seq where year = #{yearStr}
</select>
<select id="getUsersByDept" resultType="java.lang.String">
SELECT
u.id
FROM
users u
LEFT JOIN departments d ON d.id = u.dept_id
WHERE
d.`name` LIKE '%儿%'
LIMIT 1
</select>

<select id="getSmnSeq" parameterType="string" resultType="map">
select seq from lyms_smn_seq where hospital_id=#{hospitalId}
</select>

<insert id="insertSmnSeq" parameterType="map">
insert into lyms_smn_seq(hospital_id,seq) values (#{hospitalId},#{seq})
</insert>

<update id="updateSmnSeq" parameterType="map">
update lyms_smn_seq set seq = #{seq} where hospital_id=#{hospitalId}
</update>

</mapper>