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

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