SysUserMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.SysUserMapper">
  6. <resultMap type="SysUser" id="SysUserResult">
  7. <id property="userId" column="user_id" />
  8. <result property="deptId" column="dept_id" />
  9. <result property="userName" column="user_name" />
  10. <result property="nickName" column="nick_name" />
  11. <result property="email" column="email" />
  12. <result property="phonenumber" column="phonenumber" />
  13. <result property="sex" column="sex" />
  14. <result property="avatar" column="avatar" />
  15. <result property="password" column="password" />
  16. <result property="password2" column="password2" />
  17. <result property="location" column="location" />
  18. <result property="examType" column="exam_type" />
  19. <result property="regStatus" column="reg_status" />
  20. <result property="endYear" column="end_year" />
  21. <result property="inviteCode" column="invite_code" />
  22. <result property="scores" column="scores" typeHandler="com.ruoyi.system.handlers.SubjectScoreTypeHandler" />
  23. <result property="examMajor" column="exam_major" />
  24. <result property="score" column="score" />
  25. <result property="scoreLock" column="score_lock" />
  26. <result property="seatInput" column="seat_input" />
  27. <result property="examMajorName" column="exam_major_name" />
  28. <result property="directedStudy" column="directed_study" />
  29. <result property="evalCounts" column="eval_counts" />
  30. <result property="cardId" column="card_id" />
  31. <result property="bindStatus" column="bind_status" />
  32. <result property="status" column="status" />
  33. <result property="delFlag" column="del_flag" />
  34. <result property="loginIp" column="login_ip" />
  35. <result property="loginDate" column="login_date" />
  36. <result property="pwdUpdateDate" column="pwd_update_date" />
  37. <result property="createBy" column="create_by" />
  38. <result property="createTime" column="create_time" />
  39. <result property="updateBy" column="update_by" />
  40. <result property="updateTime" column="update_time" />
  41. <result property="remark" column="remark" />
  42. <result property="userType" column="user_type" />
  43. <result property="userTypeId" column="user_type_id" />
  44. <result property="accountType" column="account_type" />
  45. <result property="wxOpenId" column="wx_openid" />
  46. <association property="dept" javaType="SysDept" resultMap="deptResult" />
  47. <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
  48. </resultMap>
  49. <resultMap id="deptResult" type="SysDept">
  50. <id property="deptId" column="dept_id" />
  51. <result property="parentId" column="parent_id" />
  52. <result property="deptName" column="dept_name" />
  53. <result property="ancestors" column="ancestors" />
  54. <result property="orderNum" column="order_num" />
  55. <result property="leader" column="leader" />
  56. <result property="status" column="dept_status" />
  57. </resultMap>
  58. <resultMap id="RoleResult" type="SysRole">
  59. <id property="roleId" column="role_id" />
  60. <result property="roleName" column="role_name" />
  61. <result property="roleKey" column="role_key" />
  62. <result property="roleSort" column="role_sort" />
  63. <result property="dataScope" column="data_scope" />
  64. <result property="status" column="role_status" />
  65. </resultMap>
  66. <sql id="selectUserVo">
  67. select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_by, u.create_time, u.remark,
  68. u.location,u.exam_type,u.reg_status,u.end_year,u.invite_code,u.scores,u.exam_major,u.score,u.score_lock,u.seat_input,u.exam_major_name,u.directed_study,u.eval_counts,u.card_id,u.bind_status,u.account_type,
  69. d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
  70. r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status, u.user_type, u.user_type_id, u.wx_openid
  71. from sys_user u
  72. left join sys_dept d on u.dept_id = d.dept_id
  73. left join sys_user_role ur on u.user_id = ur.user_id
  74. left join sys_role r on r.role_id = ur.role_id
  75. </sql>
  76. <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
  77. select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader, u.user_type, u.user_type_id, u.account_type
  78. ,u.card_id,u.bind_status,u.end_year,u.location,u.invite_code,u.exam_type from sys_user u
  79. left join sys_dept d on u.dept_id = d.dept_id
  80. left join dz_cards c on u.card_id = c.card_id
  81. left join dz_agent a on CAST(u.invite_code AS UNSIGNED) = a.agent_id
  82. where u.del_flag = '0'
  83. <if test="userId != null and userId != 0">
  84. AND u.user_id = #{userId}
  85. </if>
  86. <if test="userName != null and userName != ''">
  87. AND u.user_name like concat('%', #{userName}, '%')
  88. </if>
  89. <if test="status != null and status != ''">
  90. AND u.status = #{status}
  91. </if>
  92. <if test="phonenumber != null and phonenumber != ''">
  93. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  94. </if>
  95. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  96. AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
  97. </if>
  98. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  99. AND date_format(u.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
  100. </if>
  101. <if test="deptId != null and deptId != 0">
  102. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  103. </if>
  104. <if test="userType != null and userType != ''">
  105. AND u.user_type = #{userType}
  106. </if>
  107. <if test="location != null and location != ''">
  108. AND u.location like concat('%', #{location}, '%')
  109. </if>
  110. <if test="endYear != null">
  111. AND u.end_year = #{endYear}
  112. </if>
  113. <if test="nickName != null and nickName != ''">
  114. AND u.nick_name like concat('%', #{nickName}, '%')
  115. </if>
  116. <if test="examType != null">
  117. AND u.exam_type = #{examType}
  118. </if>
  119. <if test="deptName != null and deptName != ''">
  120. AND d.dept_name like concat('%', #{deptName}, '%')
  121. </if>
  122. <if test="inviteCode != null and inviteCode != ''">
  123. AND u.invite_code like concat('%', #{inviteCode}, '%')
  124. </if>
  125. <if test="inviteDeptId != null and inviteDeptId != 0">
  126. AND a.dept_id = #{inviteDeptId}
  127. </if>
  128. <if test="usercardType != null and usercardType != ''">
  129. <choose>
  130. <when test="usercardType == '99' or usercardType == 99">
  131. AND u.card_id IS NULL
  132. </when>
  133. <when test="usercardType == '1' or usercardType == 1">
  134. AND u.card_id IS NOT NULL AND c.type IS NOT NULL AND c.type IN (1, 2, 6, 7)
  135. </when>
  136. <when test="usercardType == '9' or usercardType == 9">
  137. AND u.card_id IS NOT NULL AND c.type IS NOT NULL AND c.type = 9
  138. </when>
  139. </choose>
  140. </if>
  141. <!-- 数据范围过滤 -->
  142. ${params.dataScope}
  143. order by u.user_id desc
  144. </select>
  145. <select id="selectCardUserList" parameterType="SysUser" resultMap="SysUserResult">
  146. select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader, u.user_type, u.user_type_id, u.account_type
  147. ,u.card_id,u.bind_status,u.end_year,u.location,u.invite_code,u.exam_type from sys_user u
  148. left join sys_dept d on u.dept_id = d.dept_id
  149. left join dz_cards c on u.card_id = c.card_id
  150. left join dz_agent a on CAST(u.invite_code AS UNSIGNED) = a.agent_id
  151. where u.del_flag = '0'
  152. <if test="userId != null and userId != 0">
  153. AND u.user_id = #{userId}
  154. </if>
  155. <if test="userName != null and userName != ''">
  156. AND u.user_name like concat('%', #{userName}, '%')
  157. </if>
  158. <if test="status != null and status != ''">
  159. AND u.status = #{status}
  160. </if>
  161. <if test="phonenumber != null and phonenumber != ''">
  162. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  163. </if>
  164. <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
  165. AND date_format(u.create_time,'%Y%m%d') &gt;= date_format(#{params.beginTime},'%Y%m%d')
  166. </if>
  167. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  168. AND date_format(u.create_time,'%Y%m%d') &lt;= date_format(#{params.endTime},'%Y%m%d')
  169. </if>
  170. <if test="agentId != null and agentId != ''"> and (c.agent_id = #{agentId} or c.leaf_agent_id = #{agentId} or a.agent_id = #{agentId} OR a.agent_id IN ( SELECT t.agent_id FROM dz_agent t WHERE t.parent_id = #{agentId}))</if>
  171. <if test="deptId != null and deptId != 0">
  172. AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
  173. </if>
  174. <if test="inviteDeptId != null and inviteDeptId != 0">
  175. AND a.dept_id = #{inviteDeptId}
  176. </if>
  177. <if test="userType != null and userType != ''">
  178. AND u.user_type = #{userType}
  179. </if>
  180. <if test="location != null and location != ''">
  181. AND u.location like concat('%', #{location}, '%')
  182. </if>
  183. <if test="endYear != null">
  184. AND u.end_year = #{endYear}
  185. </if>
  186. <if test="nickName != null and nickName != ''">
  187. AND u.nick_name like concat('%', #{nickName}, '%')
  188. </if>
  189. <if test="examType != null">
  190. AND u.exam_type = #{examType}
  191. </if>
  192. <if test="deptName != null and deptName != ''">
  193. AND d.dept_name like concat('%', #{deptName}, '%')
  194. </if>
  195. <if test="inviteCode != null and inviteCode != ''">
  196. AND u.invite_code like concat('%', #{inviteCode}, '%')
  197. </if>
  198. <if test="bindStatus != null">
  199. AND u.bind_status = #{bindStatus}
  200. </if>
  201. <if test="usercardType != null and usercardType != ''">
  202. <choose>
  203. <when test="usercardType == '99' or usercardType == 99">
  204. AND u.card_id IS NULL
  205. </when>
  206. <when test="usercardType == '1' or usercardType == 1">
  207. AND u.card_id IS NOT NULL AND c.type IS NOT NULL AND c.type IN (1, 2, 6, 7)
  208. </when>
  209. <when test="usercardType == '9' or usercardType == 9">
  210. AND u.card_id IS NOT NULL AND c.type IS NOT NULL AND c.type = 9
  211. </when>
  212. </choose>
  213. </if>
  214. order by u.user_id desc
  215. </select>
  216. <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
  217. select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
  218. from sys_user u
  219. left join sys_dept d on u.dept_id = d.dept_id
  220. left join sys_user_role ur on u.user_id = ur.user_id
  221. left join sys_role r on r.role_id = ur.role_id
  222. where u.del_flag = '0' and r.role_id = #{roleId}
  223. <if test="userName != null and userName != ''">
  224. AND u.user_name like concat('%', #{userName}, '%')
  225. </if>
  226. <if test="phonenumber != null and phonenumber != ''">
  227. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  228. </if>
  229. <!-- 数据范围过滤 -->
  230. ${params.dataScope}
  231. </select>
  232. <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
  233. select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
  234. from sys_user u
  235. left join sys_dept d on u.dept_id = d.dept_id
  236. left join sys_user_role ur on u.user_id = ur.user_id
  237. left join sys_role r on r.role_id = ur.role_id
  238. where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
  239. and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
  240. <if test="userName != null and userName != ''">
  241. AND u.user_name like concat('%', #{userName}, '%')
  242. </if>
  243. <if test="phonenumber != null and phonenumber != ''">
  244. AND u.phonenumber like concat('%', #{phonenumber}, '%')
  245. </if>
  246. <!-- 数据范围过滤 -->
  247. ${params.dataScope}
  248. </select>
  249. <select id="selectPasswordByCardId" parameterType="Long" resultType="String">
  250. select u.password2 from sys_user u where u.card_id = #{cardId} and u.del_flag = '0'
  251. </select>
  252. <select id="selectPassword2ByUserIds" resultType="map">
  253. select u.user_id, u.password2 from sys_user u
  254. where u.user_id in <foreach collection="userIds" item="userId" open="(" separator="," close=")">#{userId}</foreach>
  255. and u.del_flag = '0'
  256. </select>
  257. <select id="selectUserByOpenId" parameterType="String" resultMap="SysUserResult">
  258. <include refid="selectUserVo"/>
  259. where u.wx_openid = #{openId} and u.del_flag = '0'
  260. </select>
  261. <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
  262. <include refid="selectUserVo"/>
  263. where u.user_name = #{userName} and u.del_flag = '0'
  264. </select>
  265. <select id="selectUserByPhone" parameterType="String" resultMap="SysUserResult">
  266. <include refid="selectUserVo"/>
  267. where u.phonenumber = #{phonenumber} and u.del_flag = '0'
  268. </select>
  269. <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
  270. <include refid="selectUserVo"/>
  271. where u.user_id = #{userId}
  272. </select>
  273. <select id="selectUserByCardIds" resultMap="SysUserResult">
  274. select * from sys_user u
  275. where u.card_id in <foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
  276. </select>
  277. <select id="selectUserByUserIds" resultMap="SysUserResult">
  278. select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.password2, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_by, u.create_time, u.remark,
  279. u.location,u.exam_type,u.reg_status,u.end_year,u.invite_code,u.scores,u.exam_major,u.score,u.score_lock,u.seat_input,u.exam_major_name,u.directed_study,u.eval_counts,u.card_id,u.account_type
  280. from sys_user u
  281. where u.user_id in <foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>
  282. </select>
  283. <select id="selectUserByUserNames" resultMap="SysUserResult">
  284. select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.password2, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_by, u.create_time, u.remark,
  285. u.location,u.exam_type,u.reg_status,u.end_year,u.invite_code,u.scores,u.exam_major,u.score,u.score_lock,u.seat_input,u.exam_major_name,u.directed_study,u.eval_counts,u.card_id,u.account_type
  286. from sys_user u
  287. where u.user_name in <foreach collection="userNames" item="userName" open="(" separator="," close=")">#{userName}</foreach>
  288. and u.del_flag = '0'
  289. </select>
  290. <select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
  291. select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
  292. </select>
  293. <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
  294. select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
  295. </select>
  296. <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
  297. select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
  298. </select>
  299. <select id="selectUsers" parameterType="map" resultMap="SysUserResult">
  300. select user_id, dept_id, nick_name, avatar, user_name, email,exam_type from sys_user
  301. <where>
  302. <if test="codes != null"> AND code IN <foreach collection="codes" item="v" open="(" separator="," close=")">#{v}</foreach> </if>
  303. <if test="userNames != null"> AND user_name IN <foreach collection="userNames" item="v" open="(" separator="," close=")">#{v}</foreach> </if>
  304. <if test="userIds != null">AND user_id IN <foreach collection="userIds" item="v" open="(" separator="," close=")">#{v}</foreach> </if>
  305. </where>
  306. </select>
  307. <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
  308. insert into sys_user(
  309. <if test="userId != null and userId != 0">user_id,</if>
  310. <if test="deptId != null">dept_id,</if>
  311. <if test="userName != null and userName != ''">user_name,</if>
  312. <if test="nickName != null and nickName != ''">nick_name,</if>
  313. <if test="email != null and email != ''">email,</if>
  314. <if test="avatar != null and avatar != ''">avatar,</if>
  315. <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
  316. <if test="sex != null and sex != ''">sex,</if>
  317. <if test="password != null and password != ''">password,</if>
  318. <if test="password2 != null and password2 != ''">password2,</if>
  319. <if test="status != null and status != ''">status,</if>
  320. <if test="pwdUpdateDate != null">pwd_update_date,</if>
  321. <if test="location != null and location != ''">location,</if>
  322. <if test="examType != null">exam_type,</if>
  323. <if test="regStatus != null">reg_status,</if>
  324. <if test="endYear != null">end_year,</if>
  325. <if test="inviteCode != null and inviteCode != ''">invite_code,</if>
  326. <if test="scores != null and scores != ''">scores,</if>
  327. <if test="evalCounts != null">eval_counts,</if>
  328. <if test="examMajor != null and examMajor != ''">exam_major,</if>
  329. <if test="score != null">score,</if>
  330. <if test="scoreLock != null">score_lock,</if>
  331. <if test="seatInput != null">seat_input,</if>
  332. <if test="examMajorName != null and examMajorName != ''">exam_major_name,</if>
  333. <if test="directedStudy != null and directedStudy != ''">directed_study,</if>
  334. <if test="cardId != null and cardId != ''">card_id,</if>
  335. <if test="bindStatus != null">bind_status,</if>
  336. <if test="createBy != null and createBy != ''">create_by,</if>
  337. <if test="remark != null and remark != ''">remark,</if>
  338. <if test="userType != null and userType != ''">user_type,</if>
  339. <if test="userTypeId != null">user_type_id,</if>
  340. <if test="wxOpenId != null and wxOpenId != ''">wx_openid,</if>
  341. <if test="accountType != null">account_type,</if>
  342. create_time
  343. )values(
  344. <if test="userId != null and userId != ''">#{userId},</if>
  345. <if test="deptId != null">#{deptId},</if>
  346. <if test="userName != null and userName != ''">#{userName},</if>
  347. <if test="nickName != null and nickName != ''">#{nickName},</if>
  348. <if test="email != null and email != ''">#{email},</if>
  349. <if test="avatar != null and avatar != ''">#{avatar},</if>
  350. <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
  351. <if test="sex != null and sex != ''">#{sex},</if>
  352. <if test="password != null and password != ''">#{password},</if>
  353. <if test="password2 != null and password2 != ''">#{password2},</if>
  354. <if test="status != null and status != ''">#{status},</if>
  355. <if test="pwdUpdateDate != null">#{pwdUpdateDate},</if>
  356. <if test="location != null and location != ''">#{location},</if>
  357. <if test="examType != null">#{examType},</if>
  358. <if test="regStatus != null">#{regStatus},</if>
  359. <if test="endYear != null and endYear != ''">#{endYear},</if>
  360. <if test="inviteCode != null and inviteCode != ''">#{inviteCode},</if>
  361. <if test="scores != null and scores != ''">#{scores, typeHandler=com.ruoyi.system.handlers.SubjectScoreTypeHandler},</if>
  362. <if test="evalCounts != null">#{evalCounts},</if>
  363. <if test="examMajor != null and examMajor != ''">#{examMajor},</if>
  364. <if test="score != null">#{score},</if>
  365. <if test="scoreLock != null">#{scoreLock},</if>
  366. <if test="seatInput != null">#{seatInput},</if>
  367. <if test="examMajorName != null and examMajorName != ''">#{examMajorName},</if>
  368. <if test="directedStudy != null and directedStudy != ''">#{directedStudy},</if>
  369. <if test="cardId != null and cardId != ''">#{cardId},</if>
  370. <if test="bindStatus != null">#{bindStatus},</if>
  371. <if test="createBy != null and createBy != ''">#{createBy},</if>
  372. <if test="remark != null and remark != ''">#{remark},</if>
  373. <if test="userType != null">#{userType},</if>
  374. <if test="userTypeId != null">#{userTypeId},</if>
  375. <if test="wxOpenId != null">#{wxOpenId},</if>
  376. <if test="accountType != null">#{accountType},</if>
  377. sysdate()
  378. )
  379. </insert>
  380. <update id="updateUser" parameterType="SysUser">
  381. update sys_user
  382. <set>
  383. <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
  384. <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
  385. <if test="userName != null and userName != ''">user_name = #{userName},</if>
  386. <if test="email != null ">email = #{email},</if>
  387. <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
  388. <if test="wxOpenId != null ">wx_openid = #{wxOpenId},</if>
  389. <if test="sex != null and sex != ''">sex = #{sex},</if>
  390. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  391. <if test="password != null and password != ''">password = #{password},</if>
  392. <if test="password2 != null and password2 != ''">password2 = #{password2},</if>
  393. <if test="status != null and status != ''">status = #{status},</if>
  394. <if test="location != null and location != ''">location = #{location},</if>
  395. <if test="examType != null">exam_type = #{examType},</if>
  396. <if test="regStatus != null">reg_status = #{regStatus},</if>
  397. <if test="endYear != null">end_year = #{endYear},</if>
  398. <if test="inviteCode != null and inviteCode != ''">invite_code = #{inviteCode},</if>
  399. <if test="scores != null and scores != ''">scores = #{scores, typeHandler=com.ruoyi.system.handlers.SubjectScoreTypeHandler},</if>
  400. <if test="examMajor != null and examMajor != ''">exam_major = #{examMajor},</if>
  401. <if test="score != null">score = #{score},</if>
  402. <if test="scoreLock != null">score_lock = #{scoreLock},</if>
  403. <if test="seatInput != null">seat_input = #{seatInput},</if>
  404. <if test="examMajorName != null and examMajorName != ''">exam_major_name = #{examMajorName},</if>
  405. <if test="directedStudy != null and directedStudy != ''">directed_study = #{directedStudy},</if>
  406. <if test="evalCounts != null and evalCounts != ''">eval_counts = #{evalCounts},</if>
  407. <if test="cardId != null and cardId != ''">card_id = #{cardId},</if>
  408. <if test="bindStatus != null">bind_status = #{bindStatus},</if>
  409. <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
  410. <if test="loginDate != null">login_date = #{loginDate},</if>
  411. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  412. <if test="remark != null">remark = #{remark},</if>
  413. <if test="userTypeId != null">user_type_id = #{userTypeId},</if>
  414. <if test="accountType != null">account_type = #{accountType},</if>
  415. update_time = sysdate()
  416. </set>
  417. where user_id = #{userId}
  418. </update>
  419. <update id="updateUserStatus" parameterType="SysUser">
  420. update sys_user set status = #{status}, update_time = sysdate() where user_id = #{userId}
  421. </update>
  422. <update id="updateUserAvatar" parameterType="SysUser">
  423. update sys_user set avatar = #{avatar}, update_time = sysdate() where user_id = #{userId}
  424. </update>
  425. <update id="updateLoginInfo" parameterType="SysUser">
  426. update sys_user set login_ip = #{loginIp}, login_date = #{loginDate} where user_id = #{userId}
  427. </update>
  428. <update id="resetUserPwd" parameterType="SysUser">
  429. update sys_user set pwd_update_date = sysdate(), password = #{password}, password2 = #{password2}, update_time = sysdate() where user_id = #{userId}
  430. </update>
  431. <update id="updateDirectedStudy" parameterType="Long">
  432. update sys_user set directed_study = null, update_time = sysdate() where user_id = #{userId}
  433. </update>
  434. <delete id="deleteUserById" parameterType="Long">
  435. update sys_user set del_flag = '2' where user_id = #{userId}
  436. </delete>
  437. <delete id="deleteUserPhysicalById" parameterType="Long">
  438. delete from sys_user where user_id = #{userId}
  439. </delete>
  440. <delete id="deleteUserByIds" parameterType="Long">
  441. update sys_user set del_flag = '2' where user_id in
  442. <foreach collection="array" item="userId" open="(" separator="," close=")">
  443. #{userId}
  444. </foreach>
  445. </delete>
  446. <!-- 查询所有非空的省份列表(去重) -->
  447. <select id="selectDistinctLocations" resultType="String">
  448. SELECT DISTINCT location
  449. FROM sys_user
  450. WHERE location IS NOT NULL AND location != '' AND del_flag = '0'
  451. ORDER BY location
  452. </select>
  453. </mapper>