Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

400 righe
14 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.WxCUserBasicInfoMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserBasicInfo">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  7. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  8. <result column="education" jdbcType="VARCHAR" property="education"/>
  9. <result column="sex" jdbcType="INTEGER" property="sex"/>
  10. <result column="email" jdbcType="VARCHAR" property="email"/>
  11. <result column="address" jdbcType="VARCHAR" property="address"/>
  12. <result column="poins" jdbcType="INTEGER" property="poins"/>
  13. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  14. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  15. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  16. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  17. <result column="name" jdbcType="VARCHAR" property="name"/>
  18. <result column="level" jdbcType="VARCHAR" property="level"/>
  19. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  20. <result column="credit" jdbcType="INTEGER" property="credit"/>
  21. </resultMap>
  22. <sql id="allColumns">
  23. `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,
  24. `create_date`,`update_date`,`tenant_id`,`name`,`level`,`nick_name`,`credit`
  25. </sql>
  26. <sql id="dynamicWhereConditions">
  27. where 1 = 1
  28. <if test=" null != id ">
  29. and `id` = #{id}
  30. </if>
  31. <if test=" null != tenantId ">
  32. and `tenant_id` = #{tenantId}
  33. </if>
  34. <if test=" null != phone ">
  35. and `phone` like concat('%', #{phone},'%')
  36. </if>
  37. <if test=" null != birthdate ">
  38. and `birthdate` = #{birthdate}
  39. </if>
  40. <if test=" null != education ">
  41. and `education` like concat('%', #{education},'%')
  42. </if>
  43. <if test=" null != sex ">
  44. and `sex` = #{sex}
  45. </if>
  46. <if test=" null != email ">
  47. and `email` like concat('%', #{email},'%')
  48. </if>
  49. <if test=" null != address ">
  50. and `address` like concat('%', #{address},'%')
  51. </if>
  52. <if test=" null != poins ">
  53. and `poins` = #{poins}
  54. </if>
  55. <if test=" null != credit ">
  56. and `credit` = #{credit}
  57. </if>
  58. <if test=" null != tagId ">
  59. and `tag_id` = #{tagId}
  60. </if>
  61. <if test=" null != createDate ">
  62. and `create_date` = #{createDate}
  63. </if>
  64. <if test=" null != updateDate ">
  65. and `update_date` = #{updateDate}
  66. </if>
  67. <if test=" null != name ">
  68. and `name` like concat('%', #{name},'%')
  69. </if>
  70. <if test=" null != startTime and null!=endTime">
  71. and `create_date` between #{startTime} and #{endTime}
  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.WxCUserBasicInfo" resultMap="BaseResultMap">
  82. select
  83. <include refid="allColumns"/>
  84. from wx_c_user_basic_info
  85. <include refid="dynamicWhereConditions"/>
  86. </select>
  87. <sql id="allUserColumns">
  88. c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`,
  89. cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.level,cb.nick_name
  90. </sql>
  91. <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo">
  92. update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId}
  93. and id=#{id}
  94. </update>
  95. <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserBaseVo">
  96. update wx_c_user_basic_info set id=#{newId} where tenant_id=#{tenantId}
  97. and id = #{id}
  98. </update>
  99. <select id="findCountBySex" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  100. select count(id) from wx_c_user_basic_info
  101. where sex =#{sex}
  102. <if test=" null != startTime ">
  103. and create_date &gt;= #{startTime}
  104. </if>
  105. <if test=" null != endTime">
  106. and create_date &lt;= #{endTime}
  107. </if>
  108. <if test="null != tenantId">
  109. and tenant_id =#{tenantId}
  110. </if>
  111. </select>
  112. <select id="findCountByAge" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  113. select count(id) from wx_c_user_basic_info where 1=1
  114. <if test=" null != startTime ">
  115. and create_date &gt;= #{startTime}
  116. </if>
  117. <if test=" null != endTime">
  118. and create_date &lt;= #{endTime}
  119. </if>
  120. <if test=" null != birthStartTime ">
  121. and birthdate &gt;= #{birthStartTime}
  122. </if>
  123. <if test=" null != birthEndTime">
  124. and birthdate &lt;= #{birthEndTime}
  125. </if>
  126. <if test=" null == birthStartTime and null == birthEndTime">
  127. and birthdate is null
  128. </if>
  129. <if test="null != tenantId">
  130. and tenant_id =#{tenantId}
  131. </if>
  132. </select>
  133. <select id="findCountByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  134. select count(id) from wx_c_user_basic_info where 1=1
  135. <if test=" null != startTime ">
  136. and create_date &gt;= #{startTime}
  137. </if>
  138. <if test=" null != endTime">
  139. and create_date &lt;= #{endTime}
  140. </if>
  141. <if test=" null != levelStartScore ">
  142. and poins &gt;= #{levelStartScore}
  143. </if>
  144. <if test=" null != levelEndScore">
  145. and poins &lt; #{levelEndScore}
  146. </if>
  147. <if test=" null == levelStartScore and null == levelEndScore">
  148. and poins is null
  149. </if>
  150. <if test="null != tenantId">
  151. and tenant_id =#{tenantId}
  152. </if>
  153. </select>
  154. <sql id="allColumnsOfScoreList">
  155. cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id,
  156. cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name
  157. </sql>
  158. <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  159. select <include refid="allColumnsOfScoreList"/>
  160. from wx_c_user_basic_info cub
  161. inner join wx_c_user cu on cu.id = cub.id
  162. where 1=1
  163. <if test=" null != levelStartScore ">
  164. and cub.poins &gt;= #{levelStartScore}
  165. </if>
  166. <if test=" null != levelEndScore">
  167. and cub.poins &lt;= #{levelEndScore}
  168. </if>
  169. <if test=" null == levelStartScore and null == levelEndScore">
  170. and cub.poins is null
  171. </if>
  172. <if test="null != tenantId">
  173. and cub.tenant_id =#{tenantId}
  174. </if>
  175. </select>
  176. <select id="findCount" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  177. select count(id) from wx_c_user_basic_info where 1=1
  178. <if test=" null != startTime ">
  179. and create_date &gt;= #{startTime}
  180. </if>
  181. <if test=" null != endTime">
  182. and create_date &lt; #{endTime}
  183. </if>
  184. <if test="null != tenantId">
  185. and tenant_id =#{tenantId}
  186. </if>
  187. </select>
  188. <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxCUserBasicInfoVo">
  189. <id column="id" jdbcType="BIGINT" property="id"/>
  190. <result column="phone" jdbcType="VARCHAR" property="phone"/>
  191. <result column="birthdate" jdbcType="TIMESTAMP" property="birthdate"/>
  192. <result column="education" jdbcType="VARCHAR" property="education"/>
  193. <result column="sex" jdbcType="INTEGER" property="sex"/>
  194. <result column="email" jdbcType="VARCHAR" property="email"/>
  195. <result column="address" jdbcType="VARCHAR" property="address"/>
  196. <result column="poins" jdbcType="INTEGER" property="poins"/>
  197. <result column="tag_id" jdbcType="BIGINT" property="tagId"/>
  198. <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
  199. <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
  200. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  201. <result column="name" jdbcType="VARCHAR" property="name"/>
  202. <result column="level" jdbcType="VARCHAR" property="level"/>
  203. <result column="nick_name" jdbcType="VARCHAR" property="nickName"/>
  204. <result column="tags" jdbcType="VARCHAR" property="tags"/>
  205. </resultMap>
  206. <sql id="allVoColumns">
  207. cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`,
  208. cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`,
  209. cut.`tags`
  210. </sql>
  211. <sql id="dynamicVoWhereConditions">
  212. where 1 = 1
  213. <if test=" null != id ">
  214. and cu.`id` = #{id}
  215. </if>
  216. <if test=" null != tenantId ">
  217. and cu.`tenant_id` = #{tenantId}
  218. </if>
  219. <if test=" null != phone ">
  220. and cu.`phone` like concat('%', #{phone},'%')
  221. </if>
  222. <if test=" null != birthdate ">
  223. and cu.`birthdate` = #{birthdate}
  224. </if>
  225. <if test=" null != education ">
  226. and cu.`education` like concat('%', #{education},'%')
  227. </if>
  228. <if test=" null != sex ">
  229. and cu.`sex` = #{sex}
  230. </if>
  231. <if test=" null != email ">
  232. and cu.`email` like concat('%', #{email},'%')
  233. </if>
  234. <if test=" null != address ">
  235. and cu.`address` like concat('%', #{address},'%')
  236. </if>
  237. <if test=" null != poins ">
  238. and cu.`poins` = #{poins}
  239. </if>
  240. <if test=" null != tagId ">
  241. and cu.`tag_id` = #{tagId}
  242. </if>
  243. <if test=" null != createDate ">
  244. and cu.`create_date` = #{createDate}
  245. </if>
  246. <if test=" null != updateDate ">
  247. and cu.`update_date` = #{updateDate}
  248. </if>
  249. <if test=" null != name ">
  250. and `name` like concat('%', #{name},'%')
  251. </if>
  252. <if test=" null != startTime and null!=endTime">
  253. and cu.`create_date` between #{startTime} and #{endTime}
  254. </if>
  255. <if test=" null != ids ">
  256. and id in
  257. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  258. #{idItem}
  259. </foreach>
  260. </if>
  261. <if test=" null != sortColumns">order by ${sortColumns}</if>
  262. </sql>
  263. <select id="findVoList" parameterType="com.iformall.domain.vo.WxCUserBasicInfoVo" resultMap="VoBaseResultMap">
  264. select
  265. <include refid="allVoColumns"/>
  266. from wx_c_user_basic_info cu
  267. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  268. <include refid="dynamicVoWhereConditions"/>
  269. </select>
  270. <select id="countVoList" parameterType="com.iformall.domain.vo.WxCUserBasicInfoVo" resultType="java.lang.Integer">
  271. select
  272. count(*)
  273. from wx_c_user_basic_info cu
  274. left join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  275. <include refid="dynamicVoWhereConditions"/>
  276. </select>
  277. <sql id="msgColumns">
  278. cu.`id`,cu.`phone`,cu.`email`
  279. </sql>
  280. <sql id="filterWhereConditions">
  281. where 1=1
  282. <if test="null != tenantId">
  283. and cu.tenant_id =#{tenantId}
  284. </if>
  285. <if test=" null != startTime ">
  286. and cu.create_date &gt;= #{startTime}
  287. </if>
  288. <if test=" null != endTime">
  289. and cu.create_date &lt;= #{endTime}
  290. </if>
  291. <if test=" null != levelStartScore and (0 != levelStartScore and '' != levelStartScore)">
  292. and cu.poins &gt;= #{levelStartScore}
  293. <if test=" null != levelEndScore">
  294. and cu.poins &lt; #{levelEndScore}
  295. </if>
  296. </if>
  297. <if test=" null != levelStartScore and (0 == levelStartScore or '' == levelStartScore)">
  298. and (cu.poins is null or
  299. (cu.poins &gt;= #{levelStartScore}
  300. <if test=" null != levelEndScore">
  301. and cu.poins &lt; #{levelEndScore}
  302. </if>
  303. ))
  304. </if>
  305. <if test=" null != tagIds ">
  306. and JSON_CONTAINS(JSON_ARRAY(cut.tags),JSON_ARRAY
  307. <foreach collection="tagIds" index="index" item="idItem" open="(" separator="," close=")">
  308. #{idItem}
  309. </foreach>
  310. )
  311. </if>
  312. <if test=" null != sortColumns">order by ${sortColumns}</if>
  313. </sql>
  314. <select id="findCountByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultType="java.lang.Long">
  315. select count(*) from wx_c_user_basic_info cu
  316. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  317. <include refid="filterWhereConditions"/>
  318. </select>
  319. <select id="findListByFilter" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap">
  320. select <include refid="msgColumns"/>
  321. from wx_c_user_basic_info cu
  322. join wx_c_user_tags cut on cut.`id` = cu.`tag_id`
  323. <include refid="filterWhereConditions"/>
  324. </select>
  325. </mapper>