No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

335 líneas
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" 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 != parentTenantId and '' != parentTenantId">
  140. and `parent_tenant_id` = #{parentTenantId}
  141. </if>
  142. <if test=" null != bopenId ">
  143. and `bopen_id`=#{bopenId}
  144. </if>
  145. </select>
  146. <select id="selectByWebOpenId" resultMap="BaseResultMap">
  147. select
  148. <include refid="allColumns"/>
  149. from mall_user_info
  150. where 1=1
  151. <if test=" null != webOpenId ">
  152. and `web_open_id`=#{webOpenId}
  153. </if>
  154. </select>
  155. <update id="removeWebOpenId">
  156. update mall_user_info
  157. set `web_open_id` = null
  158. where 1=1
  159. <if test=" null != tenantId and '' != tenantId">
  160. and `tenant_id` = #{tenantId}
  161. </if>
  162. <if test=" null != parentTenantId and '' != parentTenantId">
  163. and `parent_tenant_id` = #{parentTenantId}
  164. </if>
  165. <if test=" null != username ">
  166. and username=#{username}
  167. </if>
  168. <if test=" null != id ">
  169. and `id` = #{id}
  170. </if>
  171. </update>
  172. <update id="removeAllOpenId">
  173. update mall_user_info
  174. set `web_open_id` = null, `bopen_id` = null
  175. where 1=1
  176. <if test=" null != tenantId and '' != tenantId">
  177. and `tenant_id` = #{tenantId}
  178. </if>
  179. <if test=" null != parentTenantId and '' != parentTenantId">
  180. and `parent_tenant_id` = #{parentTenantId}
  181. </if>
  182. <if test=" null != username ">
  183. and username=#{username}
  184. </if>
  185. <if test=" null != id ">
  186. and `id` = #{id}
  187. </if>
  188. </update>
  189. <select id="selectByPhone" resultMap="BaseResultMap">
  190. select
  191. <include refid="allColumns"/>
  192. from mall_user_info
  193. where 1=1
  194. <if test=" null != tenantId and '' != tenantId">
  195. and `tenant_id` = #{tenantId}
  196. </if>
  197. <if test=" null != parentTenantId and '' != parentTenantId">
  198. and `parent_tenant_id` = #{parentTenantId}
  199. </if>
  200. <if test=" null != phone ">
  201. and `phone`=#{phone}
  202. </if>
  203. </select>
  204. <select id="hasButtonPermission" resultType="java.lang.Integer">
  205. SELECT 1
  206. FROM mall_user_role ur, mall_user_role_permission rp, mall_permission p
  207. WHERE rp.role_id = ur.role_id
  208. AND rp.permission_id = p.id
  209. AND p.resource_type = 1
  210. AND ur.uid = #{userId}
  211. AND p.permission = #{permission}
  212. </select>
  213. <select id="cntByUserName" resultType="java.lang.Integer">
  214. select count(*) from mall_user_info where status = 1
  215. <if test=" null != username ">
  216. and username=#{username}
  217. </if>
  218. <if test=" null != phone ">
  219. and `phone` = #{phone}
  220. </if>
  221. <if test=" null != id ">
  222. and `id` != #{id}
  223. </if>
  224. </select>
  225. <!-- 查询用户的所有权限 -->
  226. <select id="queryAllMenu" resultType="com.iformall.domain.po.MallPermission">
  227. select p.*
  228. from mall_permission p
  229. LEFT JOIN mall_role_permission rp on rp.permission_id = p.id
  230. LEFT JOIN mall_user_role ur on ur.role_id = rp.role_id
  231. where ur.uid = #{userId}
  232. </select>
  233. <!-- 查询用户的所有权限 -->
  234. <select id="queryAllPerms" resultType="string">
  235. select p.permission from mall_user_role ur
  236. LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
  237. LEFT JOIN mall_permission p on rp.permission_id = p.id
  238. where ur.uid = #{userId}
  239. </select>
  240. <!-- 查询用户的所有菜单ID -->
  241. <select id="queryAllMenuId" resultType="long">
  242. select distinct rp.permission_id from mall_user_role ur
  243. LEFT JOIN mall_role_permission rp on ur.role_id = rp.role_id
  244. where ur.uid = #{userId}
  245. </select>
  246. <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.MallUserInfoVo">
  247. <id column="id" jdbcType="BIGINT" property="id"/>
  248. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  249. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  250. <result column="username" jdbcType="VARCHAR" property="username"/>
  251. <result column="name" jdbcType="VARCHAR" property="name"/>
  252. <result column="password" jdbcType="VARCHAR" property="password"/>
  253. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  254. <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
  255. <result column="status" jdbcType="INTEGER" property="status"/>
  256. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  257. <result column="invest_rule" jdbcType="INTEGER" property="investRule"/>
  258. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  259. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  260. <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
  261. <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
  262. <result column="email" property="email"/>
  263. <result column="mall_name" jdbcType="VARCHAR" property="mallName"/>
  264. <result column="mall_group" jdbcType="VARCHAR" property="mallGroup"/>
  265. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  266. <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH"/>
  267. </resultMap>
  268. <sql id="allSafeVColumns">
  269. 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`,
  270. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
  271. </sql>
  272. <sql id="allVColumns">
  273. 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`,
  274. u.`bopen_id`,u.`web_open_id`,
  275. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`,email
  276. </sql>
  277. <select id="selectUsersByPhone" resultMap="VBaseResultMap">
  278. select
  279. <include refid="allSafeVColumns"/>
  280. from mall_user_info u
  281. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  282. where 1=1
  283. <if test=" null != phone ">
  284. and u.`phone` = #{phone}
  285. </if>
  286. </select>
  287. <select id="selectUsersByWebOpenId" resultMap="VBaseResultMap">
  288. select
  289. <include refid="allSafeVColumns"/>
  290. from mall_user_info u
  291. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  292. where 1=1
  293. <if test=" null != webOpenId ">
  294. and u.`web_open_id` = #{webOpenId}
  295. </if>
  296. </select>
  297. </mapper>