SystemUserMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.css.simulation.resource.server.infra.db.mysql.mapper.SystemUserMapper" >
  4. <select id="getUserInfo" parameterType="java.lang.String" resultType="api.common.pojo.vo.system.UserVO">
  5. SELECT
  6. id,
  7. username,
  8. nickname,
  9. photo,
  10. phone,
  11. company,
  12. role_code,
  13. use_type
  14. FROM system_user WHERE id = #{userId,jdbcType=VARCHAR}
  15. </select>
  16. <!-- 列表查询共用字段-->
  17. <sql id="pageColumn">
  18. u.id,
  19. u.username,
  20. u.nickname,
  21. u.photo,
  22. u.phone,
  23. u.company,
  24. u.role_code,
  25. u.use_type,
  26. u.visible,
  27. u.create_time,
  28. t.username as createUserName
  29. </sql>
  30. <!-- 列表查询共用查询条件-->
  31. <sql id="pageWhere">
  32. <if test="username != null and username != ''">
  33. and u.username like CONCAT('%',#{username,jdbcType=VARCHAR},'%')
  34. </if>
  35. <if test="nickname != null and nickname != ''">
  36. and u.nickname like CONCAT('%',#{nickname,jdbcType=VARCHAR},'%')
  37. </if>
  38. <if test="company != null and company != ''">
  39. and u.company like CONCAT('%',#{company,jdbcType=VARCHAR},'%')
  40. </if>
  41. <if test="roleCode != null and roleCode != ''">
  42. and u.role_code = #{roleCode,jdbcType=VARCHAR}
  43. </if>
  44. <if test="visible != null and visible != ''">
  45. and u.visible = #{visible,jdbcType=VARCHAR}
  46. </if>
  47. </sql>
  48. <select id="getUserPageLista" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
  49. SELECT
  50. <include refid="pageColumn"></include>
  51. FROM system_user u
  52. JOIN system_user t ON u.create_user_id = t.id
  53. WHERE u.is_deleted = '0' AND u.role_code &lt;&gt; '0' and u.role_code &lt;&gt; '3'
  54. <include refid="pageWhere"></include>
  55. ORDER BY u.modify_time DESC
  56. </select>
  57. <select id="getUserPageListb" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
  58. SELECT
  59. <include refid="pageColumn"></include>
  60. FROM system_user u
  61. JOIN system_user t ON u.create_user_id = t.id
  62. WHERE u.is_deleted = '0' AND u.role_code = '2'
  63. <include refid="pageWhere"></include>
  64. ORDER BY u.modify_time DESC
  65. </select>
  66. <select id="getUserPageListc" parameterType="api.common.pojo.param.system.UserParam" resultType="api.common.pojo.vo.system.UserVO">
  67. SELECT
  68. <include refid="pageColumn"></include>
  69. FROM system_user u
  70. JOIN system_user t ON u.create_user_id = t.id
  71. WHERE u.is_deleted = '0' AND u.role_code = '3'
  72. <include refid="pageWhere"></include>
  73. and u.create_user_id = #{createUserId,jdbcType=VARCHAR}
  74. ORDER BY u.modify_time DESC
  75. </select>
  76. <select id="selectCount" resultType="java.lang.Integer">
  77. select count(*)
  78. from system_user
  79. where is_deleted = '0'
  80. </select>
  81. <select id="checkUsername" parameterType="api.common.pojo.po.system.UserPO" resultType="api.common.pojo.po.system.UserPO">
  82. select
  83. id
  84. from system_user
  85. where is_deleted = '0'
  86. and username = #{username,jdbcType=VARCHAR}
  87. <if test="id != null and id != ''">
  88. and id &lt;&gt; #{id,jdbcType=VARCHAR}
  89. </if>
  90. </select>
  91. <select id="checkPassword" parameterType="api.common.pojo.vo.system.UserVO" resultType="api.common.pojo.vo.system.UserVO">
  92. select
  93. id
  94. from system_user
  95. where is_deleted = '0'
  96. and password = #{password,jdbcType=VARCHAR}
  97. and id = #{id,jdbcType=VARCHAR}
  98. </select>
  99. <insert id="insert" parameterType="api.common.pojo.po.system.UserPO">
  100. INSERT INTO system_user(
  101. id,
  102. username,
  103. password,
  104. nickname,
  105. photo,
  106. phone,
  107. company,
  108. role_code,
  109. use_type,
  110. visible,
  111. create_time,
  112. modify_time,
  113. create_user_id,
  114. modify_user_id,
  115. is_deleted
  116. )
  117. VALUES(
  118. #{id,jdbcType=VARCHAR},
  119. #{username,jdbcType=VARCHAR},
  120. #{password,jdbcType=VARCHAR},
  121. #{nickname,jdbcType=VARCHAR},
  122. #{photo,jdbcType=VARCHAR},
  123. #{phone,jdbcType=VARCHAR},
  124. #{company,jdbcType=VARCHAR},
  125. #{roleCode,jdbcType=VARCHAR},
  126. #{useType,jdbcType=VARCHAR},
  127. #{visible,jdbcType=VARCHAR},
  128. #{createTime,jdbcType=TIMESTAMP},
  129. #{modifyTime,jdbcType=TIMESTAMP},
  130. #{createUserId,jdbcType=VARCHAR},
  131. #{modifyUserId,jdbcType=VARCHAR},
  132. #{isDeleted,jdbcType=VARCHAR}
  133. )
  134. </insert>
  135. <update id="update" parameterType="api.common.pojo.po.system.UserPO">
  136. update system_user set
  137. username = #{username,jdbcType=VARCHAR},
  138. nickname = #{nickname,jdbcType=VARCHAR},
  139. <!--photo = #{photo,jdbcType=VARCHAR},-->
  140. phone = #{phone,jdbcType=VARCHAR},
  141. company = #{company,jdbcType=VARCHAR},
  142. <!--visible = #{visible,jdbcType=VARCHAR},-->
  143. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  144. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  145. where id = #{id,jdbcType=VARCHAR}
  146. </update>
  147. <update id="saveDefaultPassword" parameterType="api.common.pojo.po.system.UserPO">
  148. update system_user set
  149. password = #{password,jdbcType=VARCHAR},
  150. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  151. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  152. where id = #{id,jdbcType=VARCHAR}
  153. </update>
  154. <update id="saveVisible" parameterType="api.common.pojo.po.system.UserPO">
  155. update system_user set
  156. visible = #{visible,jdbcType=VARCHAR},
  157. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  158. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  159. where id = #{id,jdbcType=VARCHAR}
  160. </update>
  161. <update id="savePhone" parameterType="api.common.pojo.po.system.UserPO">
  162. update system_user set
  163. nickname = #{nickname,jdbcType=VARCHAR},
  164. phone = #{phone,jdbcType=VARCHAR},
  165. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  166. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  167. where id = #{id,jdbcType=VARCHAR}
  168. </update>
  169. <update id="savePassword" parameterType="api.common.pojo.po.system.UserPO">
  170. update system_user set
  171. password = #{password,jdbcType=VARCHAR},
  172. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  173. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  174. where id = #{id,jdbcType=VARCHAR}
  175. </update>
  176. <select id="getSubUser" parameterType="java.lang.String" resultType="api.common.pojo.po.system.UserPO">
  177. select * from system_user
  178. where is_deleted = '0' AND create_user_id = #{createUserId}
  179. </select>
  180. <select id="selectCreateUserIdById" resultType="java.lang.String">
  181. select create_user_id from system_user where id = #{id}
  182. </select>
  183. <select id="selectRoleCodeById" resultType="java.lang.String">
  184. select role_code from system_user where id = #{id}
  185. </select>
  186. </mapper>