AdDao.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.AdDao">
  4. <resultMap type="com.kmall.admin.entity.AdEntity" id="adMap">
  5. <result property="id" column="id"/>
  6. <result property="adPositionId" column="ad_position_id"/>
  7. <result property="mediaType" column="media_type"/>
  8. <result property="name" column="name"/>
  9. <result property="storeId" column="store_id"/>
  10. <result property="merchSn" column="merch_sn"/>
  11. <result property="link" column="link"/>
  12. <result property="imageUrl" column="image_url"/>
  13. <result property="content" column="content"/>
  14. <result property="endTime" column="end_time"/>
  15. <result property="enabled" column="enabled"/>
  16. <result property="sortOrder" column="sort_order"/>
  17. <result property="tickDiscId" column="tick_disc_id"/>
  18. </resultMap>
  19. <select id="queryObject" resultType="com.kmall.admin.entity.AdEntity">
  20. select
  21. id,
  22. ad_position_id,
  23. media_type,
  24. name,
  25. store_id,
  26. merch_sn,
  27. link,
  28. image_url,
  29. sort_order,
  30. content,
  31. end_time,
  32. enabled
  33. from mall_ad
  34. where id = #{id}
  35. </select>
  36. <select id="queryAdByTickDiscId" resultType="com.kmall.admin.entity.AdEntity">
  37. select
  38. id,
  39. ad_position_id,
  40. media_type,
  41. name,
  42. store_id,
  43. merch_sn,
  44. link,
  45. image_url,
  46. sort_order,
  47. content,
  48. end_time,
  49. enabled
  50. from mall_ad
  51. where tick_disc_id = #{tickDiscId}
  52. </select>
  53. <select id="queryList" resultType="com.kmall.admin.entity.AdEntity">
  54. select
  55. mall_ad.id,
  56. mall_ad.ad_position_id,
  57. mall_ad.media_type,
  58. mall_ad.name,
  59. mall_ad.store_id,
  60. mall_ad.merch_sn,
  61. mall_ad.link,
  62. mall_ad.image_url,
  63. mall_ad.sort_order,
  64. mall_ad.content,
  65. mall_ad.end_time,
  66. mall_ad.enabled,
  67. mall_ad_position.name ad_Position_Name
  68. from mall_ad LEFT JOIN mall_ad_position on mall_ad.ad_position_id = mall_ad_position.id
  69. left join mall_store s on mall_ad.store_id = s.id
  70. where 1=1
  71. <if test="storeId != null and storeId != ''">
  72. AND mall_ad.store_id = #{storeId}
  73. </if>
  74. <if test="merchSn != null and merchSn.trim() != ''">
  75. AND mall_ad.merch_sn = #{merchSn}
  76. </if>
  77. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  78. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  79. </if>
  80. <if test="name != null and name.trim() != ''">
  81. AND mall_ad.name LIKE concat('%',#{name},'%')
  82. </if>
  83. <choose>
  84. <when test="sidx != null and sidx.trim() != ''">
  85. order by ${sidx} ${order}
  86. </when>
  87. <otherwise>
  88. order by mall_ad.id desc
  89. </otherwise>
  90. </choose>
  91. <if test="offset != null and limit != null">
  92. limit #{offset}, #{limit}
  93. </if>
  94. </select>
  95. <select id="queryTotal" resultType="int">
  96. select count(*) from mall_ad
  97. left join mall_store s on mall_ad.store_id = s.id
  98. WHERE 1=1
  99. <if test="storeId != null and storeId != ''">
  100. AND mall_ad.store_id = #{storeId}
  101. </if>
  102. <if test="merchSn != null and merchSn.trim() != ''">
  103. AND mall_ad.merch_sn = #{merchSn}
  104. </if>
  105. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  106. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  107. </if>
  108. <if test="name != null and name.trim() != ''">
  109. AND name LIKE concat('%',#{name},'%')
  110. </if>
  111. </select>
  112. <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
  113. insert into mall_ad(
  114. `ad_position_id`,
  115. `media_type`,
  116. `name`,
  117. `store_id`,
  118. `merch_sn`,
  119. tick_disc_id,
  120. `link`,
  121. `image_url`,
  122. `sort_order`,
  123. `content`,
  124. `end_time`,
  125. `enabled`)
  126. values(
  127. #{adPositionId},
  128. #{mediaType},
  129. #{name},
  130. #{storeId},
  131. #{merchSn},
  132. #{tickDiscId},
  133. #{link},
  134. #{imageUrl},
  135. #{sortOrder},
  136. #{content},
  137. #{endTime},
  138. #{enabled})
  139. </insert>
  140. <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
  141. update mall_ad
  142. <set>
  143. <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
  144. <if test="mediaType != null">`media_type` = #{mediaType},</if>
  145. <if test="name != null">`name` = #{name},</if>
  146. <if test="storeId != null">`store_id` = #{storeId}, </if>
  147. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  148. <if test="tickDiscId != null">`tick_disc_id` = #{tickDiscId}, </if>
  149. <if test="link != null">`link` = #{link},</if>
  150. <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
  151. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  152. <if test="content != null">`content` = #{content},</if>
  153. <if test="endTime != null">`end_time` = #{endTime},</if>
  154. <if test="enabled != null">`enabled` = #{enabled}</if>
  155. </set>
  156. where id = #{id}
  157. </update>
  158. <delete id="delete">
  159. delete from mall_ad where id = #{value}
  160. </delete>
  161. <delete id="deleteBatch">
  162. delete from mall_ad where id in
  163. <foreach item="id" collection="array" open="(" separator="," close=")">
  164. #{id}
  165. </foreach>
  166. </delete>
  167. </mapper>