AppuserMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="AppuserMapper">
  5. <!--表名 -->
  6. <sql id="tableName">
  7. SYS_APP_USER
  8. </sql>
  9. <!-- 字段 -->
  10. <sql id="Field">
  11. USER_ID,
  12. USERNAME,
  13. PASSWORD,
  14. NAME,
  15. RIGHTS,
  16. ROLE_ID,
  17. LAST_LOGIN,
  18. IP,
  19. STATUS,
  20. BZ,
  21. PHONE,
  22. SFID,
  23. START_TIME,
  24. END_TIME,
  25. YEARS,
  26. EMAIL,
  27. NUMBER
  28. </sql>
  29. <!-- 字段值 -->
  30. <sql id="FieldValue">
  31. #{USER_ID},
  32. #{USERNAME},
  33. #{PASSWORD},
  34. #{NAME},
  35. #{RIGHTS},
  36. #{ROLE_ID},
  37. #{LAST_LOGIN},
  38. #{IP},
  39. #{STATUS},
  40. #{BZ},
  41. #{PHONE},
  42. #{SFID},
  43. #{START_TIME},
  44. #{END_TIME},
  45. #{YEARS},
  46. #{EMAIL},
  47. #{NUMBER}
  48. </sql>
  49. <!-- 角色表 -->
  50. <sql id="roleTableName">
  51. SYS_ROLE
  52. </sql>
  53. <!-- 列出某角色下的所有会员 -->
  54. <select id="listAllAppuserByRorlid" parameterType="pd" resultType="pd" >
  55. select
  56. USER_ID
  57. from
  58. <include refid="tableName"></include>
  59. where
  60. ROLE_ID = #{ROLE_ID}
  61. </select>
  62. <!-- 会员列表 -->
  63. <select id="userlistPage" parameterType="page" resultType="pd">
  64. select u.USER_ID,
  65. u.USERNAME,
  66. u.PASSWORD,
  67. u.LAST_LOGIN,
  68. u.NAME,
  69. u.IP,
  70. u.END_TIME,
  71. u.YEARS,
  72. u.STATUS,
  73. u.EMAIL,
  74. u.PHONE,
  75. u.NUMBER,
  76. r.ROLE_ID,
  77. r.ROLE_NAME
  78. from <include refid="tableName"></include> u, <include refid="roleTableName"></include> r
  79. where u.ROLE_ID = r.ROLE_ID
  80. and r.PARENT_ID = '2'
  81. <if test="pd.keywords != null and pd.keywords!= ''"><!-- 关键词检索 -->
  82. and (
  83. u.USERNAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  84. or
  85. u.EMAIL LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  86. or
  87. u.NUMBER LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  88. )
  89. </if>
  90. <if test="pd.ROLE_ID != null and pd.ROLE_ID != ''"><!-- 角色检索 -->
  91. and u.ROLE_ID=#{pd.ROLE_ID}
  92. </if>
  93. <if test="pd.lastLoginStart!=null and pd.lastLoginStart!=''"><!-- 到期时间检索 -->
  94. and u.END_TIME &gt;= #{pd.lastLoginStart}
  95. </if>
  96. <if test="pd.lastLoginEnd!=null and pd.lastLoginEnd!=''"><!-- 到期时间检索 -->
  97. and u.END_TIME &lt;= #{pd.lastLoginEnd}
  98. </if>
  99. <if test="pd.STATUS != null and pd.STATUS != ''"><!-- 状态检索 -->
  100. and u.STATUS=#{pd.STATUS}
  101. </if>
  102. order by u.NAME
  103. </select>
  104. <!-- 通过USERNAME获取数据 -->
  105. <select id="findByUsername" parameterType="pd" resultType="pd">
  106. select
  107. <include refid="Field"></include>
  108. from
  109. <include refid="tableName"></include>
  110. where
  111. USERNAME = #{USERNAME}
  112. </select>
  113. <!-- 通过邮箱获取数据 -->
  114. <select id="findByEmail" parameterType="pd" resultType="pd">
  115. select
  116. <include refid="Field"></include>
  117. from
  118. <include refid="tableName"></include>
  119. where
  120. EMAIL = #{EMAIL}
  121. <if test="USERNAME != null and USERNAME != ''">
  122. and USERNAME != #{USERNAME}
  123. </if>
  124. </select>
  125. <!-- 通过编号获取数据 -->
  126. <select id="findByNumber" parameterType="pd" resultType="pd">
  127. select
  128. <include refid="Field"></include>
  129. from
  130. <include refid="tableName"></include>
  131. where
  132. NUMBER = #{NUMBER}
  133. <if test="USERNAME != null and USERNAME != ''">
  134. and USERNAME != #{USERNAME}
  135. </if>
  136. </select>
  137. <!-- 新增会员 -->
  138. <insert id="saveU" parameterType="pd">
  139. insert into <include refid="tableName"></include> (
  140. <include refid="Field"></include>
  141. ) values (
  142. <include refid="FieldValue"></include>
  143. )
  144. </insert>
  145. <!-- 删除用户 -->
  146. <delete id="deleteU" parameterType="pd">
  147. delete from <include refid="tableName"></include>
  148. where
  149. USER_ID = #{USER_ID}
  150. </delete>
  151. <!-- 修改 -->
  152. <update id="editU" parameterType="pd">
  153. update <include refid="tableName"></include>
  154. set USERNAME = #{USERNAME},
  155. NAME = #{NAME},
  156. ROLE_ID = #{ROLE_ID},
  157. BZ = #{BZ},
  158. PHONE = #{PHONE},
  159. SFID = #{SFID},
  160. START_TIME = #{START_TIME},
  161. END_TIME = #{END_TIME},
  162. YEARS = #{YEARS},
  163. STATUS = #{STATUS},
  164. EMAIL = #{EMAIL},
  165. NUMBER = #{NUMBER}
  166. <if test="PASSWORD != null and PASSWORD != ''">
  167. ,PASSWORD = #{PASSWORD}
  168. </if>
  169. where
  170. USER_ID = #{USER_ID}
  171. </update>
  172. <!-- 通过ID获取数据 -->
  173. <select id="findByUiId" parameterType="pd" resultType="pd">
  174. select
  175. <include refid="Field"></include>
  176. from
  177. <include refid="tableName"></include>
  178. where
  179. USER_ID = #{USER_ID}
  180. </select>
  181. <!-- 全部会员 -->
  182. <select id="listAllUser" parameterType="pd" resultType="pd">
  183. select u.USER_ID,
  184. u.USERNAME,
  185. u.PASSWORD,
  186. u.LAST_LOGIN,
  187. u.NAME,
  188. u.IP,
  189. u.END_TIME,
  190. u.YEARS,
  191. u.STATUS,
  192. u.EMAIL,
  193. u.PHONE,
  194. u.SFID,
  195. u.NUMBER,
  196. r.ROLE_ID,
  197. r.ROLE_NAME
  198. from <include refid="tableName"></include> u, <include refid="roleTableName"></include> r
  199. where u.ROLE_ID = r.ROLE_ID
  200. and r.PARENT_ID = '2'
  201. <if test="keywords != null and keywords!= ''"><!-- 关键词检索 -->
  202. and (
  203. u.USERNAME LIKE CONCAT(CONCAT('%', #{keywords}),'%')
  204. or
  205. u.EMAIL LIKE CONCAT(CONCAT('%', #{keywords}),'%')
  206. or
  207. u.NUMBER LIKE CONCAT(CONCAT('%', #{keywords}),'%')
  208. )
  209. </if>
  210. <if test="ROLE_ID != null and ROLE_ID != ''"><!-- 角色检索 -->
  211. and u.ROLE_ID=#{ROLE_ID}
  212. </if>
  213. <if test="lastLoginStart!=null and lastLoginStart!=''"><!-- 到期时间检索 -->
  214. and u.END_TIME &gt;= #{lastLoginStart}
  215. </if>
  216. <if test="lastLoginEnd!=null and lastLoginEnd!=''"><!-- 到期时间检索 -->
  217. and u.END_TIME &lt;= #{lastLoginEnd}
  218. </if>
  219. <if test="STATUS != null and STATUS != ''"><!-- 状态检索 -->
  220. and u.STATUS=#{STATUS}
  221. </if>
  222. order by u.NAME
  223. </select>
  224. <!-- 批量删除用户 -->
  225. <delete id="deleteAllU" parameterType="String">
  226. delete from <include refid="tableName"></include>
  227. where
  228. USER_ID in
  229. <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
  230. #{item}
  231. </foreach>
  232. </delete>
  233. <!-- 获取总数 -->
  234. <select id="getAppUserCount" parameterType="String" resultType="pd">
  235. select
  236. count(USER_ID) appUserCount
  237. from
  238. <include refid="tableName"></include>
  239. </select>
  240. <!-- FH QQ313596790(青苔) -->
  241. </mapper>