UserMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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="org.dromara.business.mapper.UserMapper">
  6. <select id="selectVoPage" resultType="org.dromara.business.domain.vo.UserVo">
  7. SELECT
  8. a.id,
  9. a.login_name,
  10. a.login_pass,
  11. a.phone,
  12. a.create_at,
  13. a.update_at,
  14. a.sex,
  15. a.email,
  16. a.nick_name,
  17. a.remark,
  18. a.captcha,
  19. a.avatar,
  20. a.province,
  21. a.city,
  22. a.area,
  23. a.place_detail,
  24. a.register_ip,
  25. a.register_device,
  26. a.status,
  27. a.app_version,
  28. CASE
  29. WHEN a.status = 0 THEN '禁用'
  30. WHEN a.status = 1 THEN '启用'
  31. ELSE ''
  32. END AS statusText,
  33. a.is_locked,
  34. a.last_login_time,
  35. a.last_login_ip,
  36. a.del_flag,
  37. <!-- 实名信息处理 -->
  38. CASE
  39. WHEN b.is_pass = 1 AND b.verification_status = 'approved' THEN b.real_name
  40. ELSE '未实名'
  41. END AS real_name
  42. FROM user a
  43. LEFT JOIN user_real_info b ON a.id = b.user_id
  44. ${ew.customSqlSegment}
  45. order by a.create_at DESC
  46. </select>
  47. <select id="selectUserList" resultType="org.dromara.business.domain.vo.UserVo">
  48. SELECT
  49. a.id,
  50. a.login_name,
  51. a.login_pass,
  52. a.phone,
  53. a.create_at,
  54. a.update_at,
  55. a.sex,
  56. a.email,
  57. a.nick_name,
  58. a.remark,
  59. a.captcha,
  60. a.avatar,
  61. a.province,
  62. a.city,
  63. a.area,
  64. a.place_detail,
  65. a.register_ip,
  66. a.register_device,
  67. a.status,
  68. a.app_version,
  69. CASE
  70. WHEN a.status = 0 THEN '禁用'
  71. WHEN a.status = 1 THEN '启用'
  72. ELSE ''
  73. END AS statusText,
  74. a.is_locked,
  75. a.last_login_time,
  76. a.last_login_ip,
  77. a.del_flag,
  78. <!-- 实名信息处理 -->
  79. CASE
  80. WHEN b.is_pass = 1 AND b.verification_status = 'approved' THEN b.real_name
  81. ELSE '未实名'
  82. END AS real_name
  83. FROM user a
  84. LEFT JOIN user_real_info b ON a.id = b.user_id
  85. ${ew.customSqlSegment}
  86. order by a.create_at DESC
  87. </select>
  88. <select id="selectVoByIdInfo" resultType="org.dromara.business.domain.vo.UserVo">
  89. SELECT
  90. a.id,
  91. a.login_name,
  92. a.login_pass,
  93. a.phone,
  94. a.create_at,
  95. a.update_at,
  96. a.sex,
  97. a.email,
  98. a.nick_name,
  99. a.remark,
  100. a.captcha,
  101. a.avatar,
  102. a.province,
  103. a.city,
  104. a.area,
  105. a.place_detail,
  106. a.register_ip,
  107. a.register_device,
  108. a.status,
  109. a.app_version,
  110. CASE
  111. WHEN a.status = 0 THEN '禁用'
  112. WHEN a.status = 1 THEN '启用'
  113. ELSE ''
  114. END AS statusText,
  115. a.is_locked,
  116. a.last_login_time,
  117. a.last_login_ip,
  118. a.del_flag,
  119. <!-- 实名信息处理 -->
  120. CASE
  121. WHEN b.is_pass = 1 AND b.verification_status = 'approved' THEN b.real_name
  122. ELSE '未实名'
  123. END AS real_name
  124. FROM user a
  125. LEFT JOIN user_real_info b ON a.id = b.user_id WHERE a.id = #{id} and a.del_flag=0
  126. </select>
  127. <update id="updateUserById">
  128. UPDATE user
  129. <set>
  130. <if test="loginName != null">login_name = #{loginName},</if>
  131. <if test="loginPass != null">login_pass = #{loginPass},</if>
  132. <if test="phone != null">phone = #{phone},</if>
  133. <if test="updateAt != null">update_at = #{updateAt},</if>
  134. <if test="sex != null">sex = #{sex},</if>
  135. <if test="email != null">email = #{email},</if>
  136. <if test="nickName != null">nick_name = #{nickName},</if>
  137. <if test="remark != null">remark = #{remark},</if>
  138. <if test="captcha != null">captcha = #{captcha},</if>
  139. <if test="avatar != null">avatar = #{avatar},</if>
  140. <if test="province != null">province = #{province},</if>
  141. <if test="city != null">city = #{city},</if>
  142. <if test="area != null">area = #{area},</if>
  143. <if test="placeDetail != null">place_detail = #{placeDetail},</if>
  144. <if test="registerIp != null">register_ip = #{registerIp},</if>
  145. <if test="registerDevice != null">register_device = #{registerDevice},</if>
  146. <if test="status != null">status = #{status},</if>
  147. <if test="isLocked != null">is_locked = #{isLocked},</if>
  148. <if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
  149. <if test="lastLoginIp != null">last_login_ip = #{lastLoginIp},</if>
  150. <if test="delFlag != null">del_flag = #{delFlag},</if>
  151. </set>
  152. WHERE id = #{id}
  153. </update>
  154. <insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
  155. INSERT INTO user
  156. <trim prefix="(" suffix=")" suffixOverrides=",">
  157. <if test="loginName != null">login_name,</if>
  158. <if test="loginPass != null">login_pass,</if>
  159. <if test="phone != null">phone,</if>
  160. <if test="createAt != null">create_at,</if>
  161. <if test="updateAt != null">update_at,</if>
  162. <if test="sex != null">sex,</if>
  163. <if test="email != null">email,</if>
  164. <if test="nickName != null">nick_name,</if>
  165. <if test="remark != null">remark,</if>
  166. <if test="captcha != null">captcha,</if>
  167. <if test="avatar != null">avatar,</if>
  168. <if test="province != null">province,</if>
  169. <if test="city != null">city,</if>
  170. <if test="area != null">area,</if>
  171. <if test="placeDetail != null">place_detail,</if>
  172. <if test="registerIp != null">register_ip,</if>
  173. <if test="registerDevice != null">register_device,</if>
  174. <if test="status != null">status,</if>
  175. <if test="isLocked != null">is_locked,</if>
  176. <if test="lastLoginTime != null">last_login_time,</if>
  177. <if test="lastLoginIp != null">last_login_ip,</if>
  178. <if test="delFlag != null">del_flag,</if>
  179. </trim>
  180. VALUES
  181. <trim prefix="(" suffix=")" suffixOverrides=",">
  182. <if test="loginName != null">#{loginName},</if>
  183. <if test="loginPass != null">#{loginPass},</if>
  184. <if test="phone != null">#{phone},</if>
  185. <if test="createAt != null">#{createAt},</if>
  186. <if test="updateAt != null">#{updateAt},</if>
  187. <if test="sex != null">#{sex},</if>
  188. <if test="email != null">#{email},</if>
  189. <if test="nickName != null">#{nickName},</if>
  190. <if test="remark != null">#{remark},</if>
  191. <if test="captcha != null">#{captcha},</if>
  192. <if test="avatar != null">#{avatar},</if>
  193. <if test="province != null">#{province},</if>
  194. <if test="city != null">#{city},</if>
  195. <if test="area != null">#{area},</if>
  196. <if test="placeDetail != null">#{placeDetail},</if>
  197. <if test="registerIp != null">#{registerIp},</if>
  198. <if test="registerDevice != null">#{registerDevice},</if>
  199. <if test="status != null">#{status},</if>
  200. <if test="isLocked != null">#{isLocked},</if>
  201. <if test="lastLoginTime != null">#{lastLoginTime},</if>
  202. <if test="lastLoginIp != null">#{lastLoginIp},</if>
  203. <if test="delFlag != null">#{delFlag},</if>
  204. </trim>
  205. </insert>
  206. <update id="deleteByUserById">
  207. <choose>
  208. <!-- 如果 ids 不为空,并且每个 id > 0 -->
  209. <when test="ids != null and ids.size() > 0">
  210. UPDATE user
  211. SET del_flag = 1
  212. WHERE id IN
  213. <foreach item="id" collection="ids" open="(" separator="," close=")">
  214. #{id}
  215. </foreach>
  216. </when>
  217. <!-- 否则不执行任何操作 -->
  218. <otherwise>
  219. SELECT 1 FROM DUAL WHERE 1 = 0
  220. </otherwise>
  221. </choose>
  222. </update>
  223. <delete id="delUserRealById">
  224. DELETE FROM user_real_info WHERE user_id = #{userId}
  225. </delete>
  226. <select id="selUserInfo" resultType="org.dromara.business.domain.vo.UserVo">
  227. SELECT
  228. a.id,
  229. a.login_name,
  230. a.login_pass,
  231. a.phone,
  232. a.create_at,
  233. a.update_at,
  234. a.sex,
  235. a.email,
  236. a.nick_name,
  237. a.remark,
  238. a.captcha,
  239. a.avatar,
  240. a.province,
  241. a.city,
  242. a.area,
  243. a.place_detail,
  244. a.register_ip,
  245. a.register_device,
  246. a.status,
  247. CASE
  248. WHEN a.status = 0 THEN '禁用'
  249. WHEN a.status = 1 THEN '启用'
  250. ELSE ''
  251. END AS statusText,
  252. a.is_locked,
  253. a.last_login_time,
  254. a.last_login_ip,
  255. a.del_flag,
  256. b.real_name
  257. FROM user a
  258. LEFT JOIN user_real_info b ON a.id = b.user_id WHERE (
  259. CAST(a.id AS CHAR) LIKE CONCAT('%', #{playerNameOrId}, '%')
  260. OR a.nick_name LIKE CONCAT('%', #{playerNameOrId}, '%')
  261. )
  262. and a.del_flag=0 limit 1
  263. </select>
  264. <select id="selUserPhoneExit" resultType="org.dromara.business.domain.vo.UserVo">
  265. SELECT
  266. a.id,
  267. a.login_name,
  268. a.login_pass,
  269. a.phone,
  270. a.create_at,
  271. a.update_at,
  272. a.sex,
  273. a.email,
  274. a.nick_name,
  275. a.remark,
  276. a.captcha,
  277. a.avatar,
  278. a.province,
  279. a.city,
  280. a.area,
  281. a.place_detail,
  282. a.register_ip,
  283. a.register_device,
  284. a.status,
  285. CASE
  286. WHEN a.status = 0 THEN '禁用'
  287. WHEN a.status = 1 THEN '启用'
  288. ELSE ''
  289. END AS statusText,
  290. a.is_locked,
  291. a.last_login_time,
  292. a.last_login_ip,
  293. a.del_flag
  294. FROM user a where a.phone=#{phone} and a.del_flag=0
  295. </select>
  296. <delete id="deleteHandHistory">
  297. DELETE FROM hand_history
  298. </delete>
  299. <delete id="deleteMessageReceivers">
  300. DELETE FROM message_receivers
  301. </delete>
  302. <delete id="deleteMessage">
  303. DELETE FROM messages
  304. </delete>
  305. <delete id="deleteOperationLog">
  306. DELETE FROM operation_log
  307. </delete>
  308. <delete id="deleteParticipants">
  309. DELETE FROM participants
  310. </delete>
  311. <delete id="deletePayOrder">
  312. DELETE FROM pay_order
  313. </delete>
  314. <delete id="deletePlayerHandHistory">
  315. DELETE FROM player_hand_history
  316. </delete>
  317. <delete id="deletePlayerItems">
  318. DELETE FROM player_items
  319. </delete>
  320. <delete id="deletePlayerItemsLog">
  321. DELETE FROM players_items_log
  322. </delete>
  323. <delete id="deletePrizeDistributionItems">
  324. DELETE FROM prize_distribution_items
  325. </delete>
  326. <delete id="deletePrizeDistribution">
  327. DELETE FROM prize_distribution
  328. </delete>
  329. <delete id="deleteRewardClaims">
  330. DELETE FROM reward_claims
  331. </delete>
  332. <delete id="deleteRewardClaimsLog">
  333. DELETE FROM reward_claims_log
  334. </delete>
  335. <delete id="deleteTournamentBlindStructures">
  336. DELETE FROM tournament_blind_structures
  337. </delete>
  338. <delete id="deleteTournamentEntryConditions">
  339. DELETE FROM tournament_entry_conditions
  340. </delete>
  341. <delete id="deleteTournament">
  342. DELETE FROM tournaments
  343. </delete>
  344. <delete id="deleteUserCheckRecord">
  345. DELETE FROM user_check_record
  346. </delete>
  347. <delete id="deleteUserComplaints">
  348. DELETE FROM user_complaints
  349. </delete>
  350. <delete id="deleteUserMessageStatus">
  351. DELETE FROM user_message_status
  352. </delete>
  353. </mapper>