Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

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