UserMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.bootdo.system.dao.UserDao">
  4. <select id="get" resultType="com.bootdo.system.domain.UserDO">
  5. select `user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district`,`post`,`duty` from sys_user where user_id = #{value}
  6. </select>
  7. <select id="list" resultType="com.bootdo.system.domain.UserDO" >
  8. select
  9. `user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district`,`post`,`duty`,gy_unit_id
  10. from sys_user as us
  11. <where>
  12. <if test="userId != null and userId != ''">and us.user_id = #{userId}</if>
  13. <if test="username != null and username != ''">and us.username = #{username}</if>
  14. <if test="name != null and name != ''">and us.name = #{name}</if>
  15. <if test="password != null and password != ''">and us.password = #{password}</if>
  16. <if test="deptId != null and deptId != ''">and us.dept_id = #{deptId}</if>
  17. <if test="deptIds != null and deptIds.size() > 0">and us.dept_id in
  18. <foreach collection="deptIds" item="item" index="index" separator="," open="(" close=")">
  19. #{item}
  20. </foreach>
  21. </if>
  22. <if test="email != null and email != ''">and us.email = #{email}</if>
  23. <if test="mobile != null and mobile != ''">and us.mobile = #{mobile}</if>
  24. <if test="status != null and status != ''">and us.status = #{status}</if>
  25. <if test="userIdCreate != null and userIdCreate != ''">and us.user_id_create = #{userIdCreate}</if>
  26. <if test="gmtCreate != null and gmtCreate != ''">and us.gmt_create = #{gmtCreate}</if>
  27. <if test="gmtModified != null and gmtModified != ''">and us.gmt_modified = #{gmtModified}</if>
  28. <if test="sex != null and sex != ''">and us.sex = #{sex}</if>
  29. <if test="birth != null and birth != ''">and us.birth = #{birth}</if>
  30. <if test="picId != null and picId != ''">and us.pic_id = #{picId}</if>
  31. <if test="liveAddress != null and liveAddress != ''">and us.live_address = #{liveAddress}</if>
  32. <if test="hobby != null and hobby != ''">and us.hobby = #{hobby}</if>
  33. <if test="province != null and province != ''">and us.province = #{province}</if>
  34. <if test="city != null and city != ''">and us.city = #{city}</if>
  35. <if test="district != null and district != ''">and us.district = #{district}</if>
  36. <if test="roleType != null and roleType == 1">and NOT EXISTS ( SELECT user_id FROM sys_user_role WHERE user_id = us.user_id )</if>
  37. <if test="roleType != null and roleType == 2">and EXISTS ( SELECT user_id FROM sys_user_role WHERE user_id = us.user_id )</if>
  38. </where>
  39. <choose>
  40. <when test="sort != null and sort.trim() != ''">
  41. order by ${sort} ${order}
  42. </when>
  43. <otherwise>
  44. order by user_id desc
  45. </otherwise>
  46. </choose>
  47. <if test="offset != null and limit != null">
  48. limit #{offset}, #{limit}
  49. </if>
  50. </select>
  51. <select id="count" resultType="int">
  52. select count(*) from sys_user as us
  53. <where>
  54. <if test="userId != null and userId != ''">and us.user_id = #{userId}</if>
  55. <if test="username != null and username != ''">and us.username = #{username}</if>
  56. <if test="name != null and name != ''">and us.name = #{name}</if>
  57. <if test="password != null and password != ''">and us.password = #{password}</if>
  58. <if test="deptId != null and deptId != ''">and us.dept_id = #{deptId}</if>
  59. <if test="email != null and email != ''">and us.email = #{email}</if>
  60. <if test="mobile != null and mobile != ''">and us.mobile = #{mobile}</if>
  61. <if test="status != null and status != ''">and us.status = #{status}</if>
  62. <if test="userIdCreate != null and userIdCreate != ''">and us.user_id_create = #{userIdCreate}</if>
  63. <if test="gmtCreate != null and gmtCreate != ''">and us.gmt_create = #{gmtCreate}</if>
  64. <if test="gmtModified != null and gmtModified != ''">and us.gmt_modified = #{gmtModified}</if>
  65. <if test="sex != null and sex != ''">and us.sex = #{sex}</if>
  66. <if test="birth != null and birth != ''">and us.birth = #{birth}</if>
  67. <if test="picId != null and picId != ''">and us.pic_id = #{picId}</if>
  68. <if test="liveAddress != null and liveAddress != ''">and us.live_address = #{liveAddress}</if>
  69. <if test="hobby != null and hobby != ''">and us.hobby = #{hobby}</if>
  70. <if test="province != null and province != ''">and us.province = #{province}</if>
  71. <if test="city != null and city != ''">and us.city = #{city}</if>
  72. <if test="district != null and district != ''">and us.district = #{district}</if>
  73. <if test="roleType != null and roleType == 1">and NOT EXISTS ( SELECT user_id FROM sys_user_role WHERE user_id = us.user_id )</if>
  74. <if test="roleType != null and roleType == 2">and EXISTS ( SELECT user_id FROM sys_user_role WHERE user_id = us.user_id )</if>
  75. </where>
  76. </select>
  77. <insert id="save" parameterType="com.bootdo.system.domain.UserDO" useGeneratedKeys="true" keyProperty="userId">
  78. insert into sys_user
  79. (
  80. `username`,
  81. `name`,
  82. `password`,
  83. `dept_id`,
  84. `email`,
  85. `mobile`,
  86. `status`,
  87. `user_id_create`,
  88. `gmt_create`,
  89. `gmt_modified`,
  90. `sex`,
  91. `birth`,
  92. `pic_id`,
  93. `live_address`,
  94. `hobby`,
  95. `province`,
  96. `city`,
  97. `unit`,
  98. `district`,
  99. `post`,
  100. `duty`
  101. )
  102. values
  103. (
  104. #{username},
  105. #{name},
  106. #{password},
  107. #{deptId},
  108. #{email},
  109. #{mobile},
  110. #{status},
  111. #{userIdCreate},
  112. #{gmtCreate},
  113. #{gmtModified},
  114. #{sex},
  115. #{birth},
  116. #{picId},
  117. #{liveAddress},
  118. #{hobby},
  119. #{province},
  120. #{city},
  121. #{district},
  122. #{post},
  123. #{duty}
  124. )
  125. </insert>
  126. <update id="update" parameterType="com.bootdo.system.domain.UserDO">
  127. update sys_user
  128. <set>
  129. <if test="username != null">`username` = #{username},</if>
  130. <if test="name != null">`name` = #{name},</if>
  131. <if test="password != null">`password` = #{password},</if>
  132. <if test="deptId != null">`dept_id` = #{deptId},</if>
  133. <if test="email != null">`email` = #{email},</if>
  134. <if test="mobile != null">`mobile` = #{mobile},</if>
  135. <if test="status != null">`status` = #{status},</if>
  136. <if test="userIdCreate != null">`user_id_create` = #{userIdCreate},</if>
  137. <if test="gmtCreate != null">`gmt_create` = #{gmtCreate},</if>
  138. <if test="gmtModified != null">`gmt_modified` = #{gmtModified},</if>
  139. <if test="sex != null">`sex` = #{sex},</if>
  140. <if test="birth != null">`birth` = #{birth},</if>
  141. <if test="picId != null">`pic_id` = #{picId},</if>
  142. <if test="liveAddress != null">`live_address` = #{liveAddress},</if>
  143. <if test="hobby != null">`hobby` = #{hobby},</if>
  144. <if test="province != null">`province` = #{province},</if>
  145. <if test="city != null">`city` = #{city},</if>
  146. <!-- <if test="unit != null">`city` = #{unit},</if>-->
  147. <if test="district != null">`district` = #{district},</if>
  148. <if test="post != null">`post` = #{post},</if>
  149. <if test="duty != null">`duty` = #{duty}</if>
  150. </set>
  151. where user_id = #{userId}
  152. </update>
  153. <delete id="remove">
  154. delete from sys_user where user_id = #{value}
  155. </delete>
  156. <delete id="batchRemove">
  157. delete from sys_user where user_id in
  158. <foreach item="userId" collection="array" open="(" separator="," close=")">
  159. #{userId}
  160. </foreach>
  161. </delete>
  162. <select id="listAllDept" resultType="long">
  163. select DISTINCT dept_id from sys_user
  164. </select>
  165. <!--根据第三同步标识符和用户名称查询-->
  166. <select id="getByHobbyAndUserName" resultType="com.bootdo.system.domain.UserDO" >
  167. select
  168. `user_id`,`username`,`name`,`password`,`dept_id`,`email`,`mobile`,`status`,`user_id_create`,`gmt_create`,`gmt_modified`,`sex`,`birth`,`pic_id`,`live_address`,`hobby`,`province`,`city`,`district`,`post`,`duty`
  169. from sys_user
  170. <where>
  171. <if test="username != null and username != ''">and username = #{username}</if>
  172. <if test="hobby != null and hobby != ''">and hobby = #{hobby}</if>
  173. <if test="status != null and status != ''">and status = #{status}</if>
  174. </where>
  175. </select>
  176. <select id="getCurrUserSysList" resultType="Integer">
  177. select distinct t.`sys_flag` sysFlag from sys_menu t where t.menu_id in
  178. (select a.menu_id from sys_role_menu a where a.role_id in
  179. (select b.role_id from sys_user_role b where b.user_id=#{userId}))
  180. </select>
  181. </mapper>