You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

265 lines
9.3 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="nick_name" jdbcType="VARCHAR" property="nickName"/>
  15. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  16. <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
  17. <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
  18. <result column="flow_permission" property="flowPermission"/>
  19. </resultMap>
  20. <sql id="allSafeColumns">
  21. `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`,`flow_permission`,`web_open_id`
  22. </sql>
  23. <sql id="allColumns">
  24. `id`,`tenant_id`,`username`,`name`,`password`,`create_time`,`last_login_time`,`status`,`is_admin`,`nick_name`,`phone`,`flow_permission`,
  25. `bopen_id`,`web_open_id`
  26. </sql>
  27. <sql id="dynamicWhereConditions">
  28. where 1 = 1
  29. <if test=" null != id ">
  30. and `id` = #{id}
  31. </if>
  32. <if test=" null != tenantId ">
  33. and `tenant_id` = #{tenantId}
  34. </if>
  35. <if test=" null != username ">
  36. and `username` like concat('%', #{username},'%')
  37. </if>
  38. <if test=" null != nickName ">
  39. and `nick_name` like concat('%', #{nickName},'%')
  40. </if>
  41. <if test=" null != name ">
  42. and `name` like concat('%', #{name},'%')
  43. </if>
  44. <if test=" null != password ">
  45. and `password` like concat('%', #{password},'%')
  46. </if>
  47. <if test=" null != createTime ">
  48. and `create_time` = #{createTime}
  49. </if>
  50. <if test=" null != lastLoginTime ">
  51. and `last_login_time` = #{lastLoginTime}
  52. </if>
  53. <if test=" null != status ">
  54. and `status` = #{status}
  55. </if>
  56. <if test=" null != isAdmin ">
  57. and `is_admin` = #{isAdmin}
  58. </if>
  59. <if test=" null != phone ">
  60. and `phone` = #{phone}
  61. </if>
  62. <if test=" null != bopenId ">
  63. and `bopen_id` = #{bopenId}
  64. </if>
  65. <if test=" null != webOpenId ">
  66. and `web_open_id` = #{webOpenId}
  67. </if>
  68. <if test=" null != flowPermission ">
  69. and JSON_CONTAINS(flow_permission->'$[*]', #{flowPermission}, '$')
  70. </if>
  71. <if test=" null != ids ">
  72. and id in
  73. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  74. #{idItem}
  75. </foreach>
  76. </if>
  77. <if test=" null != sortColumns">order by ${sortColumns}</if>
  78. </sql>
  79. <select id="findList" parameterType="com.iformall.domain.po.MallUserInfo" resultMap="BaseResultMap">
  80. select
  81. <include refid="allSafeColumns"/>
  82. from mall_user_info
  83. <include refid="dynamicWhereConditions"/>
  84. </select>
  85. <select id="selectByUserName" resultMap="BaseResultMap">
  86. select
  87. <include refid="allColumns"/>
  88. from mall_user_info
  89. where 1=1
  90. <if test=" null != username ">
  91. and username=#{username}
  92. </if>
  93. </select>
  94. <select id="selectById" resultMap="BaseResultMap">
  95. select
  96. <include refid="allSafeColumns"/>
  97. from mall_user_info
  98. where 1=1
  99. <if test=" null != id ">
  100. and id=#{id}
  101. </if>
  102. </select>
  103. <select id="selectByUserNameWebOpen" resultMap="BaseResultMap">
  104. select
  105. <include refid="allColumns"/>
  106. from mall_user_info
  107. where 1=1
  108. <if test=" null != username ">
  109. and username=#{username}
  110. </if>
  111. <if test=" null != webOpenId ">
  112. and `web_open_id`=#{webOpenId}
  113. </if>
  114. </select>
  115. <select id="selectByBOpenId" resultMap="BaseResultMap">
  116. select
  117. <include refid="allSafeColumns"/>
  118. from mall_user_info
  119. where 1=1
  120. <if test=" null != tenantId ">
  121. and `tenant_id`=#{tenantId}
  122. </if>
  123. <if test=" null != bopenId ">
  124. and `bopen_id`=#{bopenId}
  125. </if>
  126. </select>
  127. <select id="selectByWebOpenId" resultMap="BaseResultMap">
  128. select
  129. <include refid="allColumns"/>
  130. from mall_user_info
  131. where 1=1
  132. <if test=" null != webOpenId ">
  133. and `web_open_id`=#{webOpenId}
  134. </if>
  135. </select>
  136. <update id="removeWebOpenId" >
  137. update mall_user_info
  138. set `web_open_id` = null
  139. where 1=1
  140. <if test=" null != tenantId ">
  141. and `tenant_id`=#{tenantId}
  142. </if>
  143. <if test=" null != username ">
  144. and username=#{username}
  145. </if>
  146. <if test=" null != id ">
  147. and `id` = #{id}
  148. </if>
  149. </update>
  150. <select id="selectByPhone" resultMap="BaseResultMap">
  151. select
  152. <include refid="allColumns"/>
  153. from mall_user_info
  154. where 1=1
  155. <if test=" null != tenantId ">
  156. and `tenant_id`=#{tenantId}
  157. </if>
  158. <if test=" null != phone ">
  159. and `phone`=#{phone}
  160. </if>
  161. </select>
  162. <select id="hasButtonPermission" resultType="java.lang.Integer">
  163. SELECT 1
  164. FROM mall_user_role ur, mall_user_role_permission rp, mall_permission p
  165. WHERE rp.role_id = ur.role_id
  166. AND rp.permission_id = p.id
  167. AND p.resource_type = 1
  168. AND ur.uid = #{userId}
  169. AND p.permission = #{permission}
  170. </select>
  171. <select id="cntByUserName" resultType="java.lang.Long">
  172. select count(*) from mall_user_info where 1=1
  173. <if test=" null != username ">
  174. and username=#{username}
  175. </if>
  176. <if test=" null != phone ">
  177. and `phone` = #{phone}
  178. </if>
  179. <if test=" null != id ">
  180. and `id` != #{id}
  181. </if>
  182. </select>
  183. <resultMap id="VBaseResultMap" type="com.iformall.domain.vo.MallUserInfoVo">
  184. <id column="id" jdbcType="BIGINT" property="id"/>
  185. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  186. <result column="username" jdbcType="VARCHAR" property="username"/>
  187. <result column="name" jdbcType="VARCHAR" property="name"/>
  188. <result column="password" jdbcType="VARCHAR" property="password"/>
  189. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  190. <result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
  191. <result column="status" jdbcType="INTEGER" property="status"/>
  192. <result column="is_admin" jdbcType="INTEGER" property="isAdmin"/>
  193. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  194. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  195. <result column="bopen_id" jdbcType="VARCHAR" property="bopenId"/>
  196. <result column="web_open_id" jdbcType="VARCHAR" property="webOpenId"/>
  197. <result column="flow_permission" property="flowPermission"/>
  198. <result column="mall_name" jdbcType="VARCHAR" property="mallName"/>
  199. <result column="mall_group" jdbcType="VARCHAR" property="mallGroup"/>
  200. <result column="img_url" jdbcType="VARCHAR" property="imgUrl"/>
  201. <result column="img_url_h" jdbcType="VARCHAR" property="imgUrlH"/>
  202. </resultMap>
  203. <sql id="allSafeVColumns">
  204. u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`nick_name`,u.`phone`,u.`flow_permission`,
  205. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`
  206. </sql>
  207. <sql id="allVColumns">
  208. u.`id`,u.`tenant_id`,u.`username`,u.`name`,u.`password`,u.`create_time`,u.`last_login_time`,u.`status`,u.`is_admin`,u.`nick_name`,u.`phone`,u.`flow_permission`,
  209. u.`bopen_id`,u.`web_open_id`,
  210. m.`name` as mall_name, m.`group` as mall_group, m.`img_url`, m.`img_url_h`
  211. </sql>
  212. <select id="selectUsersByPhone" resultMap="VBaseResultMap">
  213. select
  214. <include refid="allSafeVColumns"/>
  215. from mall_user_info u
  216. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  217. where 1=1
  218. <if test=" null != phone ">
  219. and u.`phone` = #{phone}
  220. </if>
  221. </select>
  222. <select id="selectUsersByWebOpenId" resultMap="VBaseResultMap">
  223. select
  224. <include refid="allSafeVColumns"/>
  225. from mall_user_info u
  226. left join wx_mall m on m.`tenant_id` = u.`tenant_id`
  227. where 1=1
  228. <if test=" null != webOpenId ">
  229. and u.`web_open_id` = #{webOpenId}
  230. </if>
  231. </select>
  232. </mapper>