1
0

AdDao.xml 6.1 KB

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