后台服务
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

329 rader
12 KiB

  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.iformall.mapper.MallUserInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.MallUserInfo">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="username" jdbcType="VARCHAR" property="username"/>
  9. <result column="name" jdbcType="VARCHAR" property="name"/>
  10. <result column="password" jdbcType="VARCHAR" property="password"/>
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  12. <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
  13. <result column="status" jdbcType="INTEGER" property="status"/>
  14. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  15. <result column="invest_rule" jdbcType="INTEGER" property="investRule"/>
  16. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  17. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  18. <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
  19. <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
  20. <result column="email" jdbcType="VARCHAR" property="email"/>
  21. </resultMap>
  22. <sql id="allSafeColumns">
  23. `id`,`tenant_id`,`parent_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,`web_open_id`,email
  24. </sql>
  25. <sql id="allColumns">
  26. `id`,`tenant_id`,`parent_tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`invest_rule`,`nick_name`,`phone`,
  27. `bopen_id`,`web_open_id`,email
  28. </sql>
  29. <sql id="dynamicWhereConditions">
  30. where 1 = 1
  31. <if test=" null != id ">
  32. and `id` = #{id}
  33. </if>
  34. <if test=" null != tenantId and '' != tenantId">
  35. and `tenant_id` = #{tenantId}
  36. </if>
  37. <if test=" null != parentTenantId and '' != parentTenantId">
  38. and `parent_tenant_id` = #{parentTenantId}
  39. </if>
  40. <if test=" null != username and ''!=username">
  41. and `username` like concat('%', #{username},'%')
  42. </if>
  43. <if test=" null != nickName ">
  44. and `nick_name` like concat('%', #{nickName},'%')
  45. </if>
  46. <if test=" null != name ">
  47. and `name` like concat('%', #{name},'%')
  48. </if>
  49. <if test=" null != password ">
  50. and `password` like concat('%', #{password},'%')
  51. </if>
  52. <if test=" null != createTime ">
  53. and `create_time` = #{createTime}
  54. </if>
  55. <if test=" null != lastLoginTime ">
  56. and `last_login_time` = #{lastLoginTime}
  57. </if>
  58. <if test=" null != status ">
  59. and `status` = #{status}
  60. </if>
  61. <if test=" null != isAdmin ">
  62. and `is_admin` = #{isAdmin}
  63. </if>
  64. <if test=" null != investRule ">
  65. and `invest_rule` = #{investRule}
  66. </if>
  67. <if test=" null != phone and ''!=phone">
  68. and `phone` = #{phone}
  69. </if>
  70. <if test=" null != bopenId ">
  71. and `bopen_id` = #{bopenId}
  72. </if>
  73. <if test=" null != webOpenId ">
  74. and `web_open_id` = #{webOpenId}
  75. </if>
  76. <if test=" null != email ">
  77. and `email` = #{email}
  78. </if>
  79. <if test="null != withWechatForQuery ">
  80. <if test="0 == withWechatForQuery ">
  81. and `web_open_id` is not null
  82. </if>
  83. <if test="1 == withWechatForQuery ">
  84. and `web_open_id` is null
  85. </if>
  86. </if>
  87. <if test=" null != ids ">
  88. and id in
  89. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  90. #{idItem}
  91. </foreach>
  92. </if>
  93. <if test=" null != sortColumns">order by ${sortColumns}</if>
  94. </sql>
  95. <select id="findList" parameterType="com.iformall.domain.po.MallUserInfo" resultMap="BaseResultMap">
  96. select
  97. <include refid="allSafeColumns"/>
  98. from mall_user_info
  99. <include refid="dynamicWhereConditions"/>
  100. </select>
  101. <select id="selectByUserName" resultMap="BaseResultMap">
  102. select
  103. <include refid="allColumns"/>
  104. from mall_user_info
  105. where 1=1
  106. <if test=" null != username ">
  107. and username=#{username}
  108. </if>
  109. </select>
  110. <select id="getById" resultMap="BaseResultMap">
  111. select
  112. <include refid="allSafeColumns"/>
  113. from mall_user_info
  114. where 1=1
  115. <if test=" null != id ">
  116. and id=#{id}
  117. </if>
  118. </select>
  119. <select id="selectByUserNameWebOpen" resultMap="BaseResultMap">
  120. select
  121. <include refid="allColumns"/>
  122. from mall_user_info
  123. where 1=1
  124. <if test=" null != username ">
  125. and username=#{username}
  126. </if>
  127. <if test=" null != webOpenId ">
  128. and `web_open_id`=#{webOpenId}
  129. </if>
  130. </select>
  131. <select id="selectByBOpenId" resultMap="BaseResultMap">
  132. select
  133. <include refid="allSafeColumns"/>
  134. from mall_user_info
  135. where 1=1
  136. <if test=" null != tenantId and '' != tenantId">
  137. and `tenant_id` = #{tenantId}
  138. </if>
  139. <if test=" null != bopenId ">
  140. and `bopen_id`=#{bopenId}
  141. </if>
  142. </select>
  143. <select id="selectByWebOpenId" resultMap="BaseResultMap">
  144. select
  145. <include refid="allColumns"/>
  146. from mall_user_info
  147. where 1=1
  148. <if test=" null != webOpenId ">
  149. and `web_open_id`=#{webOpenId}
  150. </if>
  151. </select>
  152. <update id="removeWebOpenId">
  153. update mall_user_info
  154. set `web_open_id` = null
  155. where 1=1
  156. <if test=" null != tenantId and '' != tenantId">
  157. and `tenant_id` = #{tenantId}
  158. </if>
  159. <if test=" null != parentTenantId and '' != parentTenantId">
  160. and `parent_tenant_id` = #{parentTenantId}
  161. </if>
  162. <if test=" null != username ">
  163. and username=#{username}
  164. </if>
  165. <if test=" null != id ">
  166. and `id` = #{id}
  167. </if>
  168. </update>
  169. <update id="removeAllOpenId">
  170. update mall_user_info
  171. set `web_open_id` = null, `bopen_id` = null
  172. where 1=1
  173. <if test=" null != tenantId and '' != tenantId">
  174. and `tenant_id` = #{tenantId}
  175. </if>
  176. <if test=" null != parentTenantId and '' != parentTenantId">
  177. and `parent_tenant_id` = #{parentTenantId}
  178. </if>
  179. <if test=" null != username ">
  180. and username=#{username}
  181. </if>
  182. <if test=" null != id ">
  183. and `id` = #{id}
  184. </if>
  185. </update>
  186. <select id="selectByPhone" resultMap="BaseResultMap">
  187. select
  188. <include refid="allColumns"/>
  189. from mall_user_info
  190. where 1=1
  191. <if test=" null != tenantId and '' != tenantId">
  192. and `tenant_id` = #{tenantId}
  193. </if>
  194. <if test=" null != phone ">
  195. and `phone`=#{phone}
  196. </if>
  197. </select>
  198. <select id="hasButtonPermission" resultType="java.lang.Integer">
  199. SELECT 1
  200. FROM mall_user_role ur, mall_user_role_permission rp, mall_permission p
  201. WHERE rp.role_id = ur.role_id
  202. AND rp.permission_id = p.id
  203. AND p.resource_type = 1
  204. AND ur.uid = #{userId}
  205. AND p.permission = #{permission}
  206. </select>
  207. <select id="cntByUserName" resultType="java.lang.Integer">
  208. select count(*) from mall_user_info where status = 1
  209. <if test=" null != username ">
  210. and username=#{username}
  211. </if>
  212. <if test=" null != phone ">
  213. and `phone` = #{phone}
  214. </if>
  215. <if test=" null != id ">
  216. and `id` != #{id}
  217. </if>
  218. </select>
  219. <!-- 查询用户的所有权限 -->
  220. <select id="queryAllMenu" resultType="com.iformall.domain.po.MallPermission">
  221. select p.*
  222. from mall_permission p
  223. LEFT JOIN mall_role_permission rp on rp.permission_id = p.id
  224. LEFT JOIN mall_user_role ur on ur.role_id = rp.role_id
  225. where ur.uid = #{userId}
  226. </select>
  227. <!-- 查询用户的所有权限 -->
  228. <select id="queryAllPerms" resultType="string">
  229. select p.permission from mall_user_role ur
  230. LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
  231. LEFT JOIN mall_permission p on rp.permission_id = p.id
  232. where ur.uid = #{userId}
  233. </select>
  234. <!-- 查询用户的所有菜单ID -->
  235. <select id="queryAllMenuId" resultType="long">
  236. select distinct rp.permission_id from mall_user_role ur
  237. LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
  238. where ur.uid = #{userId}
  239. </select>
  240. <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.MallUserInfoVo">
  241. <id column="id" jdbcType="BIGINT" property="id"/>
  242. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  243. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  244. <result column="username" jdbcType="VARCHAR" property="username"/>
  245. <result column="name" jdbcType="VARCHAR" property="name"/>
  246. <result column="password" jdbcType="VARCHAR" property="password"/>
  247. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  248. <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
  249. <result column="status" jdbcType="INTEGER" property="status"/>
  250. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  251. <result column="invest_rule" jdbcType="INTEGER" property="investRule"/>
  252. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  253. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  254. <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
  255. <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
  256. <result column="email" property="email"/>
  257. <result column="mall_name" jdbcType="VARCHAR" property="mallName"/>
  258. <result column="mall_group" jdbcType="VARCHAR" property="mallGroup"/>
  259. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  260. <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH"/>
  261. </resultMap>
  262. <sql id="allSafeVColumns">
  263. u.`id`,u.`tenant_id`,u.`parent_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`,
  264. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
  265. </sql>
  266. <sql id="allVColumns">
  267. u.`id`,u.`tenant_id`,u.`parent_tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`invest_rule`,u.`nick_name`,u.`phone`,
  268. u.`bopen_id`,u.`web_open_id`,
  269. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
  270. </sql>
  271. <select id="selectUsersByPhone" resultMap="VBaseResultMap">
  272. select
  273. <include refid="allSafeVColumns"/>
  274. from mall_user_info u
  275. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  276. where 1=1
  277. <if test=" null != phone ">
  278. and u.`phone` = #{phone}
  279. </if>
  280. </select>
  281. <select id="selectUsersByWebOpenId" resultMap="VBaseResultMap">
  282. select
  283. <include refid="allSafeVColumns"/>
  284. from mall_user_info u
  285. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  286. where 1=1
  287. <if test=" null != webOpenId ">
  288. and u.`web_open_id` = #{webOpenId}
  289. </if>
  290. </select>
  291. </mapper>