UserMapper.xml 5.8 KB

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