CouponDetailMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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.izouma.awesomeadmin.dao.CouponDetailMapper">
  4. <resultMap id="BaseResultMap" type="com.izouma.awesomeadmin.model.CouponDetail">
  5. <id column="id" property="id" jdbcType="INTEGER"/>
  6. <result column="del_flag" property="delFlag" jdbcType="CHAR"/>
  7. <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  8. <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
  9. <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
  10. <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
  11. <result column="coupon_id" property="couponId" jdbcType="INTEGER"/>
  12. <result column="store_id" property="storeId" jdbcType="INTEGER"/>
  13. <result column="coupon_code" property="couponCode" jdbcType="VARCHAR"/>
  14. <result column="use_times" property="useTimes" jdbcType="INTEGER"/>
  15. <result column="receive_flag" property="receiveFlag" jdbcType="CHAR"/>
  16. <result column="receive_time" property="receiveTime" jdbcType="TIMESTAMP"/>
  17. <result column="use_flag" property="useFlag" jdbcType="CHAR"/>
  18. <result column="use_time" property="useTime" jdbcType="TIMESTAMP"/>
  19. <result column="user_id" property="userId" jdbcType="INTEGER"/>
  20. </resultMap>
  21. <sql id="Base_Column_List">
  22. <trim suffixOverrides=",">
  23. id,
  24. del_flag,
  25. update_time,
  26. update_user,
  27. create_time,
  28. create_user,
  29. coupon_id,
  30. store_id,
  31. coupon_code,
  32. use_times,
  33. receive_flag,
  34. receive_time,
  35. use_flag,
  36. use_time,
  37. user_id,
  38. </trim>
  39. </sql>
  40. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  41. select
  42. <include refid="Base_Column_List"/>
  43. from coupon_detail
  44. where id = #{id,jdbcType=INTEGER}
  45. </select>
  46. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  47. delete from coupon_detail
  48. where id = #{id,jdbcType=INTEGER}
  49. </delete>
  50. <insert id="insertSelective" parameterType="com.izouma.awesomeadmin.model.CouponDetail" useGeneratedKeys="true"
  51. keyProperty="id">
  52. insert into coupon_detail
  53. <trim prefix="(" suffix=")" suffixOverrides=",">
  54. <if test="id!= null">
  55. id,
  56. </if>
  57. <if test="delFlag!= null">
  58. del_flag,
  59. </if>
  60. <if test="updateTime!= null">
  61. update_time,
  62. </if>
  63. <if test="updateUser!= null">
  64. update_user,
  65. </if>
  66. <if test="createTime!= null">
  67. create_time,
  68. </if>
  69. <if test="createUser!= null">
  70. create_user,
  71. </if>
  72. <if test="couponId!= null">
  73. coupon_id,
  74. </if>
  75. <if test="storeId!= null">
  76. store_id,
  77. </if>
  78. <if test="couponCode!= null">
  79. coupon_code,
  80. </if>
  81. <if test="useTimes!= null">
  82. use_times,
  83. </if>
  84. <if test="receiveFlag!= null">
  85. receive_flag,
  86. </if>
  87. <if test="receiveTime!= null">
  88. receive_time,
  89. </if>
  90. <if test="useFlag!= null">
  91. use_flag,
  92. </if>
  93. <if test="useTime!= null">
  94. use_time,
  95. </if>
  96. <if test="userId!= null">
  97. user_id,
  98. </if>
  99. </trim>
  100. <trim prefix="values (" suffix=")" suffixOverrides=",">
  101. <if test="id != null">
  102. #{id,jdbcType=INTEGER},
  103. </if>
  104. <if test="delFlag != null">
  105. #{delFlag,jdbcType=CHAR},
  106. </if>
  107. <if test="updateTime != null">
  108. #{updateTime,jdbcType=TIMESTAMP},
  109. </if>
  110. <if test="updateUser != null">
  111. #{updateUser,jdbcType=VARCHAR},
  112. </if>
  113. <if test="createTime != null">
  114. #{createTime,jdbcType=TIMESTAMP},
  115. </if>
  116. <if test="createUser != null">
  117. #{createUser,jdbcType=VARCHAR},
  118. </if>
  119. <if test="couponId != null">
  120. #{couponId,jdbcType=INTEGER},
  121. </if>
  122. <if test="storeId != null">
  123. #{storeId,jdbcType=INTEGER},
  124. </if>
  125. <if test="couponCode != null">
  126. #{couponCode,jdbcType=VARCHAR},
  127. </if>
  128. <if test="useTimes != null">
  129. #{useTimes,jdbcType=INTEGER},
  130. </if>
  131. <if test="receiveFlag != null">
  132. #{receiveFlag,jdbcType=CHAR},
  133. </if>
  134. <if test="receiveTime != null">
  135. #{receiveTime,jdbcType=TIMESTAMP},
  136. </if>
  137. <if test="useFlag != null">
  138. #{useFlag,jdbcType=CHAR},
  139. </if>
  140. <if test="useTime != null">
  141. #{useTime,jdbcType=TIMESTAMP},
  142. </if>
  143. <if test="userId != null">
  144. #{userId,jdbcType=INTEGER},
  145. </if>
  146. </trim>
  147. </insert>
  148. <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.CouponDetail">
  149. update coupon_detail
  150. <set>
  151. <if test="id != null">
  152. id= #{id,jdbcType=INTEGER},
  153. </if>
  154. <if test="delFlag != null">
  155. del_flag= #{delFlag,jdbcType=CHAR},
  156. </if>
  157. <if test="updateTime != null">
  158. update_time= #{updateTime,jdbcType=TIMESTAMP},
  159. </if>
  160. <if test="updateUser != null">
  161. update_user= #{updateUser,jdbcType=VARCHAR},
  162. </if>
  163. <if test="createTime != null">
  164. create_time= #{createTime,jdbcType=TIMESTAMP},
  165. </if>
  166. <if test="createUser != null">
  167. create_user= #{createUser,jdbcType=VARCHAR},
  168. </if>
  169. <if test="couponId != null">
  170. coupon_id= #{couponId,jdbcType=INTEGER},
  171. </if>
  172. <if test="storeId != null">
  173. store_id= #{storeId,jdbcType=INTEGER},
  174. </if>
  175. <if test="couponCode != null">
  176. coupon_code= #{couponCode,jdbcType=VARCHAR},
  177. </if>
  178. <if test="useTimes != null">
  179. use_times= #{useTimes,jdbcType=INTEGER},
  180. </if>
  181. <if test="receiveFlag != null">
  182. receive_flag= #{receiveFlag,jdbcType=CHAR},
  183. </if>
  184. <if test="receiveTime != null">
  185. receive_time= #{receiveTime,jdbcType=TIMESTAMP},
  186. </if>
  187. <if test="useFlag != null">
  188. use_flag= #{useFlag,jdbcType=CHAR},
  189. </if>
  190. <if test="useTime != null">
  191. use_time= #{useTime,jdbcType=TIMESTAMP},
  192. </if>
  193. <if test="userId != null">
  194. user_id= #{userId,jdbcType=INTEGER},
  195. </if>
  196. </set>
  197. where
  198. <if test="id != null and !&quot;&quot;.equals(id)">
  199. id = #{id,jdbcType=INTEGER}
  200. </if>
  201. <if test="idStr != null and !&quot;&quot;.equals(idStr)">
  202. id in (${idStr})
  203. </if>
  204. </update>
  205. <select id="queryCouponDetailByPage" parameterType="java.util.Map"
  206. resultMap="AllCouponDetailResult">
  207. select
  208. <include refid="Base_Column_List"/>
  209. from coupon_detail
  210. <where>
  211. and del_flag = 'N'
  212. <if test="record.idStr != null and !&quot;&quot;.equals(record.idStr)">
  213. and id in (${record.idStr})
  214. </if>
  215. <if test="record.id != null and !&quot;&quot;.equals(record.id)">
  216. and id = #{record.id}
  217. </if>
  218. <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
  219. and del_flag = #{record.delFlag}
  220. </if>
  221. <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
  222. and update_time = #{record.updateTime}
  223. </if>
  224. <if test="record.updateUser != null and !&quot;&quot;.equals(record.updateUser)">
  225. and update_user = #{record.updateUser}
  226. </if>
  227. <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
  228. and create_time = #{record.createTime}
  229. </if>
  230. <if test="record.createUser != null and !&quot;&quot;.equals(record.createUser)">
  231. and create_user = #{record.createUser}
  232. </if>
  233. <if test="record.couponId != null and !&quot;&quot;.equals(record.couponId)">
  234. and coupon_id = #{record.couponId}
  235. </if>
  236. <if test="record.storeId != null and !&quot;&quot;.equals(record.storeId)">
  237. and store_id = #{record.storeId}
  238. </if>
  239. <if test="record.couponCode != null and !&quot;&quot;.equals(record.couponCode)">
  240. and coupon_code = #{record.couponCode}
  241. </if>
  242. <if test="record.useTimes != null and !&quot;&quot;.equals(record.useTimes)">
  243. and use_times = #{record.useTimes}
  244. </if>
  245. <if test="record.receiveFlag != null and !&quot;&quot;.equals(record.receiveFlag)">
  246. and receive_flag = #{record.receiveFlag}
  247. </if>
  248. <if test="record.receiveTime != null and !&quot;&quot;.equals(record.receiveTime)">
  249. and receive_time = #{record.receiveTime}
  250. </if>
  251. <if test="record.useFlag != null and !&quot;&quot;.equals(record.useFlag)">
  252. and use_flag = #{record.useFlag}
  253. </if>
  254. <if test="record.useTime != null and !&quot;&quot;.equals(record.useTime)">
  255. and use_time = #{record.useTime}
  256. </if>
  257. <if test="record.userId != null and !&quot;&quot;.equals(record.userId)">
  258. and user_id = #{record.userId}
  259. </if>
  260. <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
  261. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  262. OR coupon_id LIKE concat('%',#{record.searchKey},'%')
  263. OR store_id LIKE concat('%',#{record.searchKey},'%')
  264. OR coupon_code LIKE concat('%',#{record.searchKey},'%')
  265. OR use_times LIKE concat('%',#{record.searchKey},'%')
  266. OR receive_flag LIKE concat('%',#{record.searchKey},'%')
  267. OR receive_time LIKE concat('%',#{record.searchKey},'%')
  268. OR use_flag LIKE concat('%',#{record.searchKey},'%')
  269. OR use_time LIKE concat('%',#{record.searchKey},'%')
  270. </trim>
  271. </if>
  272. <if test="record.advancedQuery != null and !&quot;&quot;.equals(record.advancedQuery)">
  273. <foreach item="item" index="index" collection="record.advancedQuery.split('_;')">
  274. <choose>
  275. <when test="item.indexOf('like') != -1">
  276. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  277. <if test="detailIndex == 3">
  278. concat('%',#{itemDetail},'%')
  279. </if>
  280. <if test="detailIndex &lt; 3">
  281. ${itemDetail}
  282. </if>
  283. </foreach>
  284. </when>
  285. <otherwise>
  286. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  287. <if test="detailIndex == 3">
  288. #{itemDetail}
  289. </if>
  290. <if test="detailIndex &lt; 3">
  291. ${itemDetail}
  292. </if>
  293. </foreach>
  294. </otherwise>
  295. </choose>
  296. </foreach>
  297. </if>
  298. </where>
  299. order by
  300. <if test="record.orderByStr != null and !&quot;&quot;.equals(record.orderByStr)">
  301. <trim suffixOverrides=",">
  302. <foreach item="item" index="index" separator="," collection="record.orderByStr.split('_;')">
  303. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  304. ${itemDetail}
  305. </foreach>
  306. </foreach>
  307. </trim>
  308. ,
  309. </if>
  310. id desc
  311. </select>
  312. <select id="queryAllCouponDetail" parameterType="java.util.Map"
  313. resultMap="AllCouponDetailResult">
  314. select
  315. <include refid="Base_Column_List"/>
  316. from coupon_detail
  317. <where>
  318. and del_flag = 'N'
  319. <if test="idStr != null and !&quot;&quot;.equals(idStr)">
  320. and id in (${idStr})
  321. </if>
  322. <if test="id != null and !&quot;&quot;.equals(id)">
  323. and id = #{id}
  324. </if>
  325. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
  326. and del_flag = #{delFlag}
  327. </if>
  328. <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
  329. and update_time = #{updateTime}
  330. </if>
  331. <if test="updateUser != null and !&quot;&quot;.equals(updateUser)">
  332. and update_user = #{updateUser}
  333. </if>
  334. <if test="createTime != null and !&quot;&quot;.equals(createTime)">
  335. and create_time = #{createTime}
  336. </if>
  337. <if test="createUser != null and !&quot;&quot;.equals(createUser)">
  338. and create_user = #{createUser}
  339. </if>
  340. <if test="couponId != null and !&quot;&quot;.equals(couponId)">
  341. and coupon_id = #{couponId}
  342. </if>
  343. <if test="storeId != null and !&quot;&quot;.equals(storeId)">
  344. and store_id = #{storeId}
  345. </if>
  346. <if test="couponCode != null and !&quot;&quot;.equals(couponCode)">
  347. and coupon_code = #{couponCode}
  348. </if>
  349. <if test="useTimes != null and !&quot;&quot;.equals(useTimes)">
  350. and use_times = #{useTimes}
  351. </if>
  352. <if test="receiveFlag != null and !&quot;&quot;.equals(receiveFlag)">
  353. and receive_flag = #{receiveFlag}
  354. </if>
  355. <if test="receiveTime != null and !&quot;&quot;.equals(receiveTime)">
  356. and receive_time = #{receiveTime}
  357. </if>
  358. <if test="useFlag != null and !&quot;&quot;.equals(useFlag)">
  359. and use_flag = #{useFlag}
  360. </if>
  361. <if test="useTime != null and !&quot;&quot;.equals(useTime)">
  362. and use_time = #{useTime}
  363. </if>
  364. <if test="userId != null and !&quot;&quot;.equals(userId)">
  365. and user_id = #{userId}
  366. </if>
  367. <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
  368. <trim prefix="and (" suffix=")" prefixOverrides="OR">
  369. OR coupon_id LIKE concat('%',#{searchKey},'%')
  370. OR store_id LIKE concat('%',#{searchKey},'%')
  371. OR coupon_code LIKE concat('%',#{searchKey},'%')
  372. OR use_times LIKE concat('%',#{searchKey},'%')
  373. OR receive_flag LIKE concat('%',#{searchKey},'%')
  374. OR receive_time LIKE concat('%',#{searchKey},'%')
  375. OR use_flag LIKE concat('%',#{searchKey},'%')
  376. OR use_time LIKE concat('%',#{searchKey},'%')
  377. </trim>
  378. </if>
  379. <if test="advancedQuery != null and !&quot;&quot;.equals(advancedQuery)">
  380. <foreach item="item" index="index" collection="advancedQuery.split('_;')">
  381. <choose>
  382. <when test="item.indexOf('like') != -1">
  383. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  384. <if test="detailIndex == 3">
  385. concat('%',#{itemDetail},'%')
  386. </if>
  387. <if test="detailIndex &lt; 3">
  388. ${itemDetail}
  389. </if>
  390. </foreach>
  391. </when>
  392. <otherwise>
  393. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  394. <if test="detailIndex == 3">
  395. #{itemDetail}
  396. </if>
  397. <if test="detailIndex &lt; 3">
  398. ${itemDetail}
  399. </if>
  400. </foreach>
  401. </otherwise>
  402. </choose>
  403. </foreach>
  404. </if>
  405. </where>
  406. order by
  407. <if test="orderByStr != null and !&quot;&quot;.equals(orderByStr)">
  408. <trim suffixOverrides=",">
  409. <foreach item="item" index="index" separator="," collection="orderByStr.split('_;')">
  410. <foreach item="itemDetail" index="detailIndex" collection="item.split('_,')">
  411. ${itemDetail}
  412. </foreach>
  413. </foreach>
  414. </trim>
  415. ,
  416. </if>
  417. id desc
  418. </select>
  419. <select id="queryCouponDetail" parameterType="java.util.Map"
  420. resultType="com.izouma.awesomeadmin.model.CouponDetail">
  421. select
  422. <include refid="Base_Column_List"/>
  423. from coupon_detail
  424. <where>
  425. and del_flag = 'N'
  426. <if test="id != null and !&quot;&quot;.equals(id)">
  427. and id = #{id}
  428. </if>
  429. <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
  430. and del_flag = #{delFlag}
  431. </if>
  432. <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
  433. and update_time = #{updateTime}
  434. </if>
  435. <if test="updateUser != null and !&quot;&quot;.equals(updateUser)">
  436. and update_user = #{updateUser}
  437. </if>
  438. <if test="createTime != null and !&quot;&quot;.equals(createTime)">
  439. and create_time = #{createTime}
  440. </if>
  441. <if test="createUser != null and !&quot;&quot;.equals(createUser)">
  442. and create_user = #{createUser}
  443. </if>
  444. <if test="couponId != null and !&quot;&quot;.equals(couponId)">
  445. and coupon_id = #{couponId}
  446. </if>
  447. <if test="storeId != null and !&quot;&quot;.equals(storeId)">
  448. and store_id = #{storeId}
  449. </if>
  450. <if test="couponCode != null and !&quot;&quot;.equals(couponCode)">
  451. and coupon_code = #{couponCode}
  452. </if>
  453. <if test="useTimes != null and !&quot;&quot;.equals(useTimes)">
  454. and use_times = #{useTimes}
  455. </if>
  456. <if test="receiveFlag != null and !&quot;&quot;.equals(receiveFlag)">
  457. and receive_flag = #{receiveFlag}
  458. </if>
  459. <if test="receiveTime != null and !&quot;&quot;.equals(receiveTime)">
  460. and receive_time = #{receiveTime}
  461. </if>
  462. <if test="useFlag != null and !&quot;&quot;.equals(useFlag)">
  463. and use_flag = #{useFlag}
  464. </if>
  465. <if test="useTime != null and !&quot;&quot;.equals(useTime)">
  466. and use_time = #{useTime}
  467. </if>
  468. <if test="userId != null and !&quot;&quot;.equals(userId)">
  469. and user_id = #{userId}
  470. </if>
  471. </where>
  472. LIMIT 1
  473. </select>
  474. <update id="delete">
  475. UPDATE coupon_detail SET del_flag = 'Y'
  476. where
  477. <if test="id != null and !&quot;&quot;.equals(id)">
  478. id = #{id,jdbcType=INTEGER}
  479. </if>
  480. <if test="idStr != null and !&quot;&quot;.equals(idStr)">
  481. id in (${idStr})
  482. </if>
  483. </update>
  484. <select id="query" parameterType="java.util.Map" resultType="com.izouma.awesomeadmin.model.CouponDetail">
  485. select
  486. <include refid="Base_Column_List"/>
  487. from coupon_detail
  488. <where>
  489. and del_flag = 'N'
  490. </where>
  491. order by id desc
  492. </select>
  493. <resultMap id="AllCouponDetailResult" type="com.izouma.awesomeadmin.model.CouponDetail" extends="BaseResultMap">
  494. <association property="userInfo"
  495. javaType="com.izouma.awesomeadmin.model.UserInfo"
  496. select="com.izouma.awesomeadmin.dao.UserInfoMapper.querySingleUserInfo"
  497. column="{ id = user_id }"/>
  498. </resultMap>
  499. </mapper>