UserMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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.book.dao.cps.mapper.UserMapper">
  4. <resultMap id="BaseResultMap" type="com.book.dao.cps.pojo.User">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="openid" jdbcType="VARCHAR" property="openid"/>
  7. <result column="unionid" jdbcType="VARCHAR" property="unionid"/>
  8. <result column="visitor" jdbcType="VARCHAR" property="visitor"/>
  9. <result column="nickname" jdbcType="VARCHAR" property="nickname"/>
  10. <result column="sex" jdbcType="OTHER" property="sex"/>
  11. <result column="mobile" jdbcType="CHAR" property="mobile"/>
  12. <result column="avatar" jdbcType="VARCHAR" property="avatar"/>
  13. <result column="is_subscribe" jdbcType="OTHER" property="isSubscribe"/>
  14. <result column="subscription_extend" jdbcType="OTHER" property="subscriptionExtend"/>
  15. <result column="subscribe_time" jdbcType="INTEGER" property="subscribeTime"/>
  16. <result column="book_category_ids" jdbcType="VARCHAR" property="bookCategoryIds"/>
  17. <result column="operate_time" jdbcType="INTEGER" property="operateTime"/>
  18. <result column="is_pay" jdbcType="OTHER" property="isPay"/>
  19. <result column="kandian" jdbcType="INTEGER" property="kandian"/>
  20. <result column="free_kandian" jdbcType="INTEGER" property="freeKandian"/>
  21. <result column="vip_endtime" jdbcType="INTEGER" property="vipEndtime"/>
  22. <result column="register_ip" jdbcType="VARCHAR" property="registerIp"/>
  23. <result column="country" jdbcType="VARCHAR" property="country"/>
  24. <result column="area" jdbcType="VARCHAR" property="area"/>
  25. <result column="province" jdbcType="VARCHAR" property="province"/>
  26. <result column="city" jdbcType="VARCHAR" property="city"/>
  27. <result column="isp" jdbcType="VARCHAR" property="isp"/>
  28. <result column="channel_id" jdbcType="INTEGER" property="channelId"/>
  29. <result column="state" jdbcType="OTHER" property="state"/>
  30. <result column="createtime" jdbcType="INTEGER" property="createtime"/>
  31. <result column="updatetime" jdbcType="INTEGER" property="updatetime"/>
  32. </resultMap>
  33. <sql id="Base_Column_List">
  34. id
  35. , openid, unionid, visitor, nickname, sex, mobile, avatar, is_subscribe, subscription_extend,
  36. subscribe_time, book_category_ids, operate_time, is_pay, kandian, free_kandian, vip_endtime,
  37. register_ip, country, area, province, city, isp, channel_id, `state`, createtime,
  38. updatetime
  39. </sql>
  40. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  41. select
  42. <include refid="Base_Column_List"/>
  43. from user
  44. where id = #{id,jdbcType=BIGINT}
  45. </select>
  46. <select id="selectByUser" resultMap="BaseResultMap" parameterType="com.book.dao.cps.pojo.User">
  47. select id from user
  48. <trim prefix="WHERE" prefixOverrides="AND | OR">
  49. <if test="openid!=null and openid!=''">
  50. and openid != #{openid}
  51. </if>
  52. <if test="mobile!=null and mobile!=''">
  53. and mobile != #{mobile}
  54. </if>
  55. <if test="channel_id!=null and channel_id!=0">
  56. and channel_id != #{channel_id}
  57. </if>
  58. </trim>
  59. </select>
  60. <select id="selectByOpenId" resultMap="BaseResultMap">
  61. SELECT *
  62. from user
  63. WHERE openid = #{openid}
  64. </select>
  65. <select id="selectListByPushMap" resultMap="BaseResultMap" parameterType="map">
  66. SELECT * FROM user
  67. <trim prefix="WHERE" prefixOverrides="AND | OR">
  68. <if test="openid!=null and openid!=''">
  69. and openid = #{openid}
  70. </if>
  71. <if test="channel_id!=null and channel_id!=0">
  72. and channel_id = #{channel_id}
  73. </if>
  74. <if test="sex!=null and sex!='-1'">
  75. and sex = #{sex}
  76. </if>
  77. <if test="tag!=null and tag!='-1'">
  78. and (
  79. tag like CONCAT(#{tag}, ',%')
  80. or tag like CONCAT('%,',#{tag})
  81. or tag like CONCAT('%,',#{tag}, ',%')
  82. )
  83. </if>
  84. <if test="is_pay!=null and is_pay!='-1'">
  85. and is_pay = #{is_pay}
  86. </if>
  87. <if test="kandian_max!=null and kandian_max!=''">
  88. and kandian &lt;= #{kandian_max}
  89. </if>
  90. <if test="kandian_min!=null and kandian_min!=''">
  91. and kandian &gt;= #{kandian_min}
  92. </if>
  93. <if test="subscribe_time!=null and subscribe_time!='-1'">
  94. and subscribe_time &gt;= #{subscribe_time}
  95. </if>
  96. and operate_time &gt; (UNIX_TIMESTAMP(NOW()) - 172800)
  97. and state ='1'
  98. and is_subscribe = '1'
  99. </trim>
  100. </select>
  101. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  102. delete
  103. from user
  104. where id = #{id,jdbcType=BIGINT}
  105. </delete>
  106. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.User"
  107. useGeneratedKeys="true">
  108. insert into user (openid, unionid, visitor,
  109. nickname, sex, mobile, avatar,
  110. is_subscribe, subscription_extend, subscribe_time,
  111. book_category_ids, operate_time, is_pay,
  112. kandian, free_kandian, vip_endtime,
  113. register_ip, country, area,
  114. province, city, isp,
  115. channel_id, `state`, createtime,
  116. updatetime)
  117. values (#{openid,jdbcType=VARCHAR}, #{unionid,jdbcType=VARCHAR}, #{visitor,jdbcType=VARCHAR},
  118. #{nickname,jdbcType=VARCHAR}, #{sex,jdbcType=OTHER}, #{mobile,jdbcType=CHAR},
  119. #{avatar,jdbcType=VARCHAR},
  120. #{isSubscribe,jdbcType=OTHER}, #{subscriptionExtend,jdbcType=OTHER}, #{subscribeTime,jdbcType=INTEGER},
  121. #{bookCategoryIds,jdbcType=VARCHAR}, #{operateTime,jdbcType=INTEGER}, #{isPay,jdbcType=OTHER},
  122. #{kandian,jdbcType=INTEGER}, #{freeKandian,jdbcType=INTEGER}, #{vipEndtime,jdbcType=INTEGER},
  123. #{registerIp,jdbcType=VARCHAR}, #{country,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR},
  124. #{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{isp,jdbcType=VARCHAR},
  125. #{channelId,jdbcType=INTEGER}, #{state,jdbcType=OTHER}, #{createtime,jdbcType=INTEGER},
  126. #{updatetime,jdbcType=INTEGER})
  127. </insert>
  128. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.User"
  129. useGeneratedKeys="true">
  130. insert into user
  131. <trim prefix="(" suffix=")" suffixOverrides=",">
  132. <if test="openid != null">
  133. openid,
  134. </if>
  135. <if test="unionid != null">
  136. unionid,
  137. </if>
  138. <if test="visitor != null">
  139. visitor,
  140. </if>
  141. <if test="nickname != null">
  142. nickname,
  143. </if>
  144. <if test="sex != null">
  145. sex,
  146. </if>
  147. <if test="mobile != null">
  148. mobile,
  149. </if>
  150. <if test="avatar != null">
  151. avatar,
  152. </if>
  153. <if test="isSubscribe != null">
  154. is_subscribe,
  155. </if>
  156. <if test="subscriptionExtend != null">
  157. subscription_extend,
  158. </if>
  159. <if test="subscribeTime != null">
  160. subscribe_time,
  161. </if>
  162. <if test="bookCategoryIds != null">
  163. book_category_ids,
  164. </if>
  165. <if test="operateTime != null">
  166. operate_time,
  167. </if>
  168. <if test="isPay != null">
  169. is_pay,
  170. </if>
  171. <if test="kandian != null">
  172. kandian,
  173. </if>
  174. <if test="freeKandian != null">
  175. free_kandian,
  176. </if>
  177. <if test="vipEndtime != null">
  178. vip_endtime,
  179. </if>
  180. <if test="registerIp != null">
  181. register_ip,
  182. </if>
  183. <if test="country != null">
  184. country,
  185. </if>
  186. <if test="area != null">
  187. area,
  188. </if>
  189. <if test="province != null">
  190. province,
  191. </if>
  192. <if test="city != null">
  193. city,
  194. </if>
  195. <if test="isp != null">
  196. isp,
  197. </if>
  198. <if test="channelId != null">
  199. channel_id,
  200. </if>
  201. <if test="state != null">
  202. `state`,
  203. </if>
  204. <if test="createtime != null">
  205. createtime,
  206. </if>
  207. <if test="updatetime != null">
  208. updatetime,
  209. </if>
  210. </trim>
  211. <trim prefix="values (" suffix=")" suffixOverrides=",">
  212. <if test="openid != null">
  213. #{openid,jdbcType=VARCHAR},
  214. </if>
  215. <if test="unionid != null">
  216. #{unionid,jdbcType=VARCHAR},
  217. </if>
  218. <if test="visitor != null">
  219. #{visitor,jdbcType=VARCHAR},
  220. </if>
  221. <if test="nickname != null">
  222. #{nickname,jdbcType=VARCHAR},
  223. </if>
  224. <if test="sex != null">
  225. #{sex,jdbcType=OTHER},
  226. </if>
  227. <if test="mobile != null">
  228. #{mobile,jdbcType=CHAR},
  229. </if>
  230. <if test="avatar != null">
  231. #{avatar,jdbcType=VARCHAR},
  232. </if>
  233. <if test="isSubscribe != null">
  234. #{isSubscribe,jdbcType=OTHER},
  235. </if>
  236. <if test="subscriptionExtend != null">
  237. #{subscriptionExtend,jdbcType=OTHER},
  238. </if>
  239. <if test="subscribeTime != null">
  240. #{subscribeTime,jdbcType=INTEGER},
  241. </if>
  242. <if test="bookCategoryIds != null">
  243. #{bookCategoryIds,jdbcType=VARCHAR},
  244. </if>
  245. <if test="operateTime != null">
  246. #{operateTime,jdbcType=INTEGER},
  247. </if>
  248. <if test="isPay != null">
  249. #{isPay,jdbcType=OTHER},
  250. </if>
  251. <if test="kandian != null">
  252. #{kandian,jdbcType=INTEGER},
  253. </if>
  254. <if test="freeKandian != null">
  255. #{freeKandian,jdbcType=INTEGER},
  256. </if>
  257. <if test="vipEndtime != null">
  258. #{vipEndtime,jdbcType=INTEGER},
  259. </if>
  260. <if test="registerIp != null">
  261. #{registerIp,jdbcType=VARCHAR},
  262. </if>
  263. <if test="country != null">
  264. #{country,jdbcType=VARCHAR},
  265. </if>
  266. <if test="area != null">
  267. #{area,jdbcType=VARCHAR},
  268. </if>
  269. <if test="province != null">
  270. #{province,jdbcType=VARCHAR},
  271. </if>
  272. <if test="city != null">
  273. #{city,jdbcType=VARCHAR},
  274. </if>
  275. <if test="isp != null">
  276. #{isp,jdbcType=VARCHAR},
  277. </if>
  278. <if test="channelId != null">
  279. #{channelId,jdbcType=INTEGER},
  280. </if>
  281. <if test="state != null">
  282. #{state,jdbcType=OTHER},
  283. </if>
  284. <if test="createtime != null">
  285. #{createtime,jdbcType=INTEGER},
  286. </if>
  287. <if test="updatetime != null">
  288. #{updatetime,jdbcType=INTEGER},
  289. </if>
  290. </trim>
  291. </insert>
  292. <update id="updateByPrimaryKeySelective" parameterType="com.book.dao.cps.pojo.User">
  293. update user
  294. <set>
  295. <if test="openid != null">
  296. openid = #{openid,jdbcType=VARCHAR},
  297. </if>
  298. <if test="unionid != null">
  299. unionid = #{unionid,jdbcType=VARCHAR},
  300. </if>
  301. <if test="visitor != null">
  302. visitor = #{visitor,jdbcType=VARCHAR},
  303. </if>
  304. <if test="nickname != null">
  305. nickname = #{nickname,jdbcType=VARCHAR},
  306. </if>
  307. <if test="sex != null">
  308. sex = #{sex,jdbcType=OTHER},
  309. </if>
  310. <if test="mobile != null">
  311. mobile = #{mobile,jdbcType=CHAR},
  312. </if>
  313. <if test="avatar != null">
  314. avatar = #{avatar,jdbcType=VARCHAR},
  315. </if>
  316. <if test="isSubscribe != null">
  317. is_subscribe = #{isSubscribe,jdbcType=OTHER},
  318. </if>
  319. <if test="subscriptionExtend != null">
  320. subscription_extend = #{subscriptionExtend,jdbcType=OTHER},
  321. </if>
  322. <if test="subscribeTime != null">
  323. subscribe_time = #{subscribeTime,jdbcType=INTEGER},
  324. </if>
  325. <if test="bookCategoryIds != null">
  326. book_category_ids = #{bookCategoryIds,jdbcType=VARCHAR},
  327. </if>
  328. <if test="operateTime != null">
  329. operate_time = #{operateTime,jdbcType=INTEGER},
  330. </if>
  331. <if test="isPay != null">
  332. is_pay = #{isPay,jdbcType=OTHER},
  333. </if>
  334. <if test="kandian != null">
  335. kandian = #{kandian,jdbcType=INTEGER},
  336. </if>
  337. <if test="freeKandian != null">
  338. free_kandian = #{freeKandian,jdbcType=INTEGER},
  339. </if>
  340. <if test="vipEndtime != null">
  341. vip_endtime = #{vipEndtime,jdbcType=INTEGER},
  342. </if>
  343. <if test="registerIp != null">
  344. register_ip = #{registerIp,jdbcType=VARCHAR},
  345. </if>
  346. <if test="country != null">
  347. country = #{country,jdbcType=VARCHAR},
  348. </if>
  349. <if test="area != null">
  350. area = #{area,jdbcType=VARCHAR},
  351. </if>
  352. <if test="province != null">
  353. province = #{province,jdbcType=VARCHAR},
  354. </if>
  355. <if test="city != null">
  356. city = #{city,jdbcType=VARCHAR},
  357. </if>
  358. <if test="isp != null">
  359. isp = #{isp,jdbcType=VARCHAR},
  360. </if>
  361. <if test="channelId != null">
  362. channel_id = #{channelId,jdbcType=INTEGER},
  363. </if>
  364. <if test="state != null">
  365. `state` = #{state,jdbcType=OTHER},
  366. </if>
  367. <if test="createtime != null">
  368. createtime = #{createtime,jdbcType=INTEGER},
  369. </if>
  370. <if test="updatetime != null">
  371. updatetime = #{updatetime,jdbcType=INTEGER},
  372. </if>
  373. </set>
  374. where id = #{id,jdbcType=BIGINT}
  375. </update>
  376. <update id="updateByPrimaryKey" parameterType="com.book.dao.cps.pojo.User">
  377. update user
  378. set openid = #{openid,jdbcType=VARCHAR},
  379. unionid = #{unionid,jdbcType=VARCHAR},
  380. visitor = #{visitor,jdbcType=VARCHAR},
  381. nickname = #{nickname,jdbcType=VARCHAR},
  382. sex = #{sex,jdbcType=OTHER},
  383. mobile = #{mobile,jdbcType=CHAR},
  384. avatar = #{avatar,jdbcType=VARCHAR},
  385. is_subscribe = #{isSubscribe,jdbcType=OTHER},
  386. subscription_extend = #{subscriptionExtend,jdbcType=OTHER},
  387. subscribe_time = #{subscribeTime,jdbcType=INTEGER},
  388. book_category_ids = #{bookCategoryIds,jdbcType=VARCHAR},
  389. operate_time = #{operateTime,jdbcType=INTEGER},
  390. is_pay = #{isPay,jdbcType=OTHER},
  391. kandian = #{kandian,jdbcType=INTEGER},
  392. free_kandian = #{freeKandian,jdbcType=INTEGER},
  393. vip_endtime = #{vipEndtime,jdbcType=INTEGER},
  394. register_ip = #{registerIp,jdbcType=VARCHAR},
  395. country = #{country,jdbcType=VARCHAR},
  396. area = #{area,jdbcType=VARCHAR},
  397. province = #{province,jdbcType=VARCHAR},
  398. city = #{city,jdbcType=VARCHAR},
  399. isp = #{isp,jdbcType=VARCHAR},
  400. channel_id = #{channelId,jdbcType=INTEGER},
  401. `state` = #{state,jdbcType=OTHER},
  402. createtime = #{createtime,jdbcType=INTEGER},
  403. updatetime = #{updatetime,jdbcType=INTEGER}
  404. where id = #{id,jdbcType=BIGINT}
  405. </update>
  406. <update id="updateUserKandian">
  407. update user
  408. set kandian=#{kandian},
  409. free_kandian=#{freekandian},
  410. updatetime=#{updateTime}
  411. where id = #{user.id}
  412. and kandian = #{user.kandian}
  413. and free_kandian = #{user.freeKandian}
  414. </update>
  415. <update id="updateOperateTimeByOpenid">
  416. update user
  417. set operate_time =#{operateTime}
  418. , updatetime=#{operateTime}
  419. where openid = #{openid}
  420. </update>
  421. </mapper>