Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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