1
0

CouponDao.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.kmall.admin.dao.CouponDao">
  4. <resultMap type="com.kmall.admin.entity.CouponEntity" id="couponMap">
  5. <result property="id" column="id"/>
  6. <result property="name" column="name"/>
  7. <result property="typeMoney" column="type_money"/>
  8. <result property="sendType" column="send_type"/>
  9. <result property="minAmount" column="min_amount"/>
  10. <result property="maxAmount" column="max_amount"/>
  11. <result property="sendStartDate" column="send_start_date"/>
  12. <result property="sendEndDate" column="send_end_date"/>
  13. <result property="useStartDate" column="use_start_date"/>
  14. <result property="useEndDate" column="use_end_date"/>
  15. <result property="minGoodsAmount" column="min_goods_amount"/>
  16. <result property="isAll" column="is_all"/>
  17. </resultMap>
  18. <sql id="conditions">
  19. <where>
  20. <if test="sendType != null">and a.`send_type` = #{sendType}</if>
  21. <if test="name != null and name.trim() != ''">
  22. AND a.name LIKE concat('%',#{name},'%')
  23. </if>
  24. </where>
  25. </sql>
  26. <select id="queryObject" resultType="com.kmall.admin.entity.CouponEntity">
  27. select
  28. `id`,
  29. `name`,
  30. `type_money`,
  31. `send_type`,
  32. `min_amount`,
  33. `max_amount`,
  34. `send_start_date`,
  35. `send_end_date`,
  36. `use_start_date`,
  37. `use_end_date`,
  38. `min_goods_amount`,
  39. `is_all`
  40. from mall_coupon
  41. where id = #{id}
  42. </select>
  43. <select id="queryList" resultType="com.kmall.admin.entity.CouponEntity">
  44. select
  45. `id`,
  46. `name`,
  47. `type_money`,
  48. `send_type`,
  49. `min_amount`,
  50. `max_amount`,
  51. `send_start_date`,
  52. `send_end_date`,
  53. `use_start_date`,
  54. `use_end_date`,
  55. `min_goods_amount`,
  56. `is_all`
  57. from mall_coupon a
  58. <include refid="conditions"/>
  59. <choose>
  60. <when test="sidx != null and sidx.trim() != ''">
  61. order by ${sidx} ${order}
  62. </when>
  63. <otherwise>
  64. order by a.id desc
  65. </otherwise>
  66. </choose>
  67. <if test="offset != null and limit != null">
  68. limit #{offset}, #{limit}
  69. </if>
  70. </select>
  71. <select id="queryTotal" resultType="int">
  72. select count(*) from mall_coupon a
  73. <include refid="conditions"/>
  74. </select>
  75. <insert id="save" parameterType="com.kmall.admin.entity.CouponEntity" useGeneratedKeys="true" keyProperty="id">
  76. insert into mall_coupon(
  77. `name`,
  78. `type_money`,
  79. `send_type`,
  80. `min_amount`,
  81. `max_amount`,
  82. `send_start_date`,
  83. `send_end_date`,
  84. `use_start_date`,
  85. `use_end_date`,
  86. `min_goods_amount`,
  87. `is_all`)
  88. values(
  89. #{name},
  90. #{typeMoney},
  91. #{sendType},
  92. #{minAmount},
  93. #{maxAmount},
  94. #{sendStartDate},
  95. #{sendEndDate},
  96. #{useStartDate},
  97. #{useEndDate},
  98. #{minGoodsAmount},
  99. #{isAll})
  100. </insert>
  101. <update id="update" parameterType="com.kmall.admin.entity.CouponEntity">
  102. update mall_coupon
  103. <set>
  104. <if test="name != null">`name` = #{name},</if>
  105. <if test="typeMoney != null">`type_money` = #{typeMoney},</if>
  106. <if test="sendType != null">`send_type` = #{sendType},</if>
  107. <if test="minAmount != null">`min_amount` = #{minAmount},</if>
  108. <if test="maxAmount != null">`max_amount` = #{maxAmount},</if>
  109. <if test="sendStartDate != null">`send_start_date` = #{sendStartDate},</if>
  110. <if test="sendEndDate != null">`send_end_date` = #{sendEndDate},</if>
  111. <if test="useStartDate != null">`use_start_date` = #{useStartDate},</if>
  112. <if test="useEndDate != null">`use_end_date` = #{useEndDate},</if>
  113. <if test="minGoodsAmount != null">`min_goods_amount` = #{minGoodsAmount},</if>
  114. <if test="isAll != null">`is_all` = #{isAll},</if>
  115. </set>
  116. where id = #{id}
  117. </update>
  118. <delete id="delete">
  119. delete from mall_coupon where id = #{value}
  120. </delete>
  121. <delete id="deleteBatch">
  122. delete from mall_coupon where id in
  123. <foreach item="id" collection="array" open="(" separator="," close=")">
  124. #{id}
  125. </foreach>
  126. </delete>
  127. </mapper>