25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

301 satır
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.WxCUserMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUser">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="open_id" jdbcType="VARCHAR" property="openId"/>
  8. <result column="union_id" jdbcType="VARCHAR" property="unionId"/>
  9. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  10. <result column="gender" jdbcType="INTEGER" property="gender"/>
  11. <result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/>
  12. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  13. <result column="pure_phone" jdbcType="VARCHAR" property="purePhone"/>
  14. <result column="city" jdbcType="VARCHAR" property="city"/>
  15. <result column="province" jdbcType="VARCHAR" property="province"/>
  16. <result column="language" jdbcType="VARCHAR" property="language"/>
  17. <result column="country_code" jdbcType="VARCHAR" property="countryCode"/>
  18. <result column="register_ip" jdbcType="VARCHAR" property="registerIp"/>
  19. <result column="verify_code_phone" jdbcType="VARCHAR" property="verifyCodePhone"/>
  20. <result column="qrcode_source" jdbcType="VARCHAR" property="qrcodeSource"/>
  21. <result column="scene" jdbcType="VARCHAR" property="scene"/>
  22. <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/>
  23. <result column="session_key" jdbcType="VARCHAR" property="sessionKey"/>
  24. <result column="score" jdbcType="INTEGER" property="score"/>
  25. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  26. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  27. <result column="app_id" jdbcType="VARCHAR" property="appId"/>
  28. <result column="token" jdbcType="VARCHAR" property="token"/>
  29. <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
  30. <result column="latitude" jdbcType="DECIMAL" property="latitude"/>
  31. <result column="longitude" jdbcType="DECIMAL" property="longitude"/>
  32. <result column="login_count" jdbcType="INTEGER" property="loginCount"/>
  33. <result column="extra_info" jdbcType="VARCHAR" property="extraInfo"/>
  34. <result column="is_subscribe" jdbcType="TINYINT" property="isSubscribe"/>
  35. <result column="open_app_id" jdbcType="VARCHAR" property="openAppId"/>
  36. <result column="mp_open_id" jdbcType="VARCHAR" property="mpOpenId"/>
  37. <result column="mp_app_id" jdbcType="VARCHAR" property="mpAppId"/>
  38. <result column="mp_subscribe" jdbcType="TINYINT" property="mpSubscribe"/>
  39. <result column="mp_subscribe_time" jdbcType="TIMESTAMP" property="mpSubscribeTime"/>
  40. <result column="mp_subscribe_scene" jdbcType="VARCHAR" property="mpSubscribeScene"/>
  41. <result column="subs_open_id" jdbcType="VARCHAR" property="subsOpenId"/>
  42. <result column="subs_app_id" jdbcType="VARCHAR" property="subsAppId"/>
  43. <result column="subs_subscribe" jdbcType="TINYINT" property="subsSubscribe"/>
  44. <result column="subs_subscribe_time" jdbcType="TIMESTAMP" property="subsSubscribeTime"/>
  45. <result column="subs_subscribe_scene" jdbcType="VARCHAR" property="subsSubscribeScene"/>
  46. <result column="credit" jdbcType="INTEGER" property="credit"/>
  47. <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/>
  48. </resultMap>
  49. <sql id="allColumns">
  50. `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`,
  51. `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`,
  52. `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`,
  53. `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`,
  54. `login_count`, `extra_info`, `is_subscribe`,
  55. `open_app_id`,
  56. `mp_open_id`,`mp_app_id`,`mp_subscribe`,`mp_subscribe_time`,`mp_subscribe_scene`,
  57. `subs_open_id`,`subs_app_id`,`subs_subscribe`,`subs_subscribe_time`,`subs_subscribe_scene`,`credit`,`active_time`
  58. </sql>
  59. <sql id="dynamicWhereConditions">
  60. where 1 = 1
  61. <if test=" null != id ">
  62. and `id` = #{id}
  63. </if>
  64. <if test=" null != tenantId ">
  65. and `tenant_id`= #{tenantId}
  66. </if>
  67. <if test=" null != openId ">
  68. and `open_id` = #{openId}
  69. </if>
  70. <if test=" null != unionId ">
  71. and `union_id` = #{unionId}
  72. </if>
  73. <if test=" null != nickName ">
  74. and `nick_name` like concat('%', #{nickName},'%')
  75. </if>
  76. <if test=" null != gender ">
  77. and `gender` = #{gender}
  78. </if>
  79. <if test=" null != avatarUrl ">
  80. and `avatar_url` like concat('%', #{avatarUrl},'%')
  81. </if>
  82. <if test=" null != phone ">
  83. and `phone` like concat('%', #{phone},'%')
  84. </if>
  85. <if test=" null != purePhone ">
  86. and `pure_phone` like concat('%', #{purePhone},'%')
  87. </if>
  88. <if test=" null != city ">
  89. and `city` like concat('%', #{city},'%')
  90. </if>
  91. <if test=" null != province ">
  92. and `province` like concat('%', #{province},'%')
  93. </if>
  94. <if test=" null != language ">
  95. and `language` like concat('%', #{language},'%')
  96. </if>
  97. <if test=" null != countryCode ">
  98. and `country_code` like concat('%', #{countryCode},'%')
  99. </if>
  100. <if test=" null != registerIp ">
  101. and `register_ip` like concat('%', #{registerIp},'%')
  102. </if>
  103. <if test=" null != verifyCodePhone ">
  104. and `verify_code_phone` like concat('%', #{verifyCodePhone},'%')
  105. </if>
  106. <if test=" null != qrcodeSource ">
  107. and `qrcode_source` like concat('%', #{qrcodeSource},'%')
  108. </if>
  109. <if test=" null != scene ">
  110. and `scene` like concat('%', #{scene},'%')
  111. </if>
  112. <if test=" null != sceneAddress ">
  113. and `scene_address` like concat('%', #{sceneAddress},'%')
  114. </if>
  115. <if test=" null != sessionKey ">
  116. and `session_key` like concat('%', #{sessionKey},'%')
  117. </if>
  118. <if test=" null != score ">
  119. and `score` = #{score}
  120. </if>
  121. <if test=" null != updateDate ">
  122. and `update_date` = #{updateDate}
  123. </if>
  124. <if test=" null != createDate ">
  125. and `create_date` = #{createDate}
  126. </if>
  127. <if test=" null != appId ">
  128. and `app_id` like concat('%', #{appId},'%')
  129. </if>
  130. <if test=" null != token ">
  131. and `token` like concat('%', #{token},'%')
  132. </if>
  133. <if test=" null != expireTime ">
  134. and `expire_time` = #{expireTime}
  135. </if>
  136. <if test=" null != latitude ">
  137. and `latitude` = #{latitude}
  138. </if>
  139. <if test=" null != longitude ">
  140. and `longitude` = #{longitude}
  141. </if>
  142. <if test=" null != loginCount ">
  143. and `login_count` = #{loginCount}
  144. </if>
  145. <if test=" null != extraInfo ">
  146. and `extra_info` = #{extraInfo}
  147. </if>
  148. <if test=" null != isSubscribe ">
  149. and `is_subscribe` = #{isSubscribe}
  150. </if>
  151. <if test=" null != openAppId ">
  152. and `open_app_id` = #{openAppId}
  153. </if>
  154. <if test=" null != mpOpenId ">
  155. and `mp_open_id` = #{mpOpenId}
  156. </if>
  157. <if test=" null != mpAppId ">
  158. and `mp_app_id` = #{mpAppId}
  159. </if>
  160. <if test=" null != subsOpenId ">
  161. and `subs_open_id` = #{subsOpenId}
  162. </if>
  163. <if test=" null != subsAppId ">
  164. and `subs_app_id` = #{subsAppId}
  165. </if>
  166. <if test=" null != credit ">
  167. and `credit` = #{credit}
  168. </if>
  169. <if test=" null != ids ">
  170. and id in
  171. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  172. #{idItem}
  173. </foreach>
  174. </if>
  175. <if test=" null != sortColumns">order by ${sortColumns}</if>
  176. </sql>
  177. <select id="findList" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap">
  178. select
  179. <include refid="allColumns"/>
  180. from wx_c_user
  181. <include refid="dynamicWhereConditions"/>
  182. </select>
  183. <select id="findByOpenId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap">
  184. select * from wx_c_user
  185. where `app_id` = #{appId} and `open_id` = #{openId}
  186. </select>
  187. <select id="findByUnionId" parameterType="com.iformall.domain.po.WxCUser" resultMap="BaseResultMap">
  188. select * from wx_c_user
  189. where `open_app_id` = #{openAppId} and `union_id` = #{unionId}
  190. </select>
  191. <select id="findByToken" resultMap="BaseResultMap">
  192. select * from wx_c_user
  193. where `token` = #{token}
  194. </select>
  195. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  196. select count(id) from wx_c_user where 1=1
  197. <if test=" null != sex ">
  198. and gender =#{sex}
  199. </if>
  200. <if test=" null != startTime ">
  201. and create_date &gt;= #{startTime}
  202. </if>
  203. <if test=" null != endTime">
  204. and create_date &lt; #{endTime}
  205. </if>
  206. <if test="null != tenantId">
  207. and tenant_id =#{tenantId}
  208. </if>
  209. </select>
  210. <select id="listByChannel" resultMap="BaseResultMap" >
  211. select id,nick_name,phone,create_date,scene_address from wx_c_user where 1=1
  212. <if test="null != tenantId">
  213. and tenant_id =#{tenantId}
  214. </if>
  215. <if test=" null != startDate ">
  216. and create_date &gt;= #{startDate}
  217. </if>
  218. <if test=" null != endDate">
  219. and create_date &lt; #{endDate}
  220. </if>
  221. <if test=" sceneList!= null ">
  222. and scene_address in
  223. <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
  224. #{scene}
  225. </foreach>
  226. </if>
  227. <if test=" null != sortColumns"> order by ${sortColumns} </if>
  228. <if test=" null == sortColumns"> order by create_date desc </if>
  229. </select>
  230. <select id="countByChannel" resultType="java.lang.Long" >
  231. select count(id) from wx_c_user where 1=1
  232. <if test="null != tenantId">
  233. and tenant_id =#{tenantId}
  234. </if>
  235. <if test=" null != startDate ">
  236. and create_date &gt;= #{startDate}
  237. </if>
  238. <if test=" null != endDate">
  239. and create_date &lt; #{endDate}
  240. </if>
  241. <if test=" sceneList!= null ">
  242. and scene_address in
  243. <foreach collection="sceneList" index="index" item="scene" open="(" separator="," close=")">
  244. #{scene}
  245. </foreach>
  246. </if>
  247. </select>
  248. <select id="checkCountByTenantOpenId" resultType="hashmap" >
  249. select * from (select tenant_id, open_id, count(tenant_id+open_id) as u_count from wx_c_user group by tenant_id, open_id) t where t.u_count >= 2
  250. </select>
  251. </mapper>