AdDao.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. s.store_name 'storeName',
  87. s.merch_name 'merchName'
  88. from mall_ad LEFT JOIN mall_ad_position on mall_ad.ad_position_id = mall_ad_position.id
  89. left join mall_store s on mall_ad.store_id = s.id
  90. where 1=1
  91. <if test="storeId != null and storeId != ''">
  92. AND mall_ad.store_id = #{storeId}
  93. </if>
  94. <if test="merchSn != null and merchSn.trim() != ''">
  95. AND mall_ad.merch_sn = #{merchSn}
  96. </if>
  97. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  98. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  99. </if>
  100. <if test="name != null and name.trim() != ''">
  101. AND mall_ad.name LIKE concat('%',#{name},'%')
  102. </if>
  103. <choose>
  104. <when test="sidx != null and sidx.trim() != ''">
  105. order by ${sidx} ${order}
  106. </when>
  107. <otherwise>
  108. order by mall_ad.id desc
  109. </otherwise>
  110. </choose>
  111. <if test="offset != null and limit != null">
  112. limit #{offset}, #{limit}
  113. </if>
  114. </select>
  115. <select id="queryTotal" resultType="int">
  116. select count(*) from mall_ad
  117. left join mall_store s on mall_ad.store_id = s.id
  118. WHERE 1=1
  119. <if test="storeId != null and storeId != ''">
  120. AND mall_ad.store_id = #{storeId}
  121. </if>
  122. <if test="merchSn != null and merchSn.trim() != ''">
  123. AND mall_ad.merch_sn = #{merchSn}
  124. </if>
  125. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  126. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  127. </if>
  128. <if test="name != null and name.trim() != ''">
  129. AND name LIKE concat('%',#{name},'%')
  130. </if>
  131. </select>
  132. <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
  133. insert into mall_ad(
  134. `ad_position_id`,
  135. `media_type`,
  136. `name`,
  137. `store_id`,
  138. `merch_sn`,
  139. tick_disc_id,
  140. store_topic_id,
  141. `link`,
  142. `image_url`,
  143. `sort_order`,
  144. `content`,
  145. `end_time`,
  146. `enabled`)
  147. values(
  148. #{adPositionId},
  149. #{mediaType},
  150. #{name},
  151. #{storeId},
  152. #{merchSn},
  153. #{tickDiscId},
  154. #{storeTopicId},
  155. #{link},
  156. #{imageUrl},
  157. #{sortOrder},
  158. #{content},
  159. #{endTime},
  160. #{enabled})
  161. </insert>
  162. <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
  163. update mall_ad
  164. <set>
  165. <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
  166. <if test="mediaType != null">`media_type` = #{mediaType},</if>
  167. <if test="name != null">`name` = #{name},</if>
  168. <if test="storeId != null">`store_id` = #{storeId}, </if>
  169. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  170. <if test="tickDiscId != null">`tick_disc_id` = #{tickDiscId}, </if>
  171. <if test="storeTopicId != null">`store_topic_id` = #{storeTopicId}, </if>
  172. <if test="link != null">`link` = #{link},</if>
  173. <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
  174. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  175. <if test="content != null">`content` = #{content},</if>
  176. <if test="endTime != null">`end_time` = #{endTime},</if>
  177. <if test="enabled != null">`enabled` = #{enabled}</if>
  178. </set>
  179. where id = #{id}
  180. </update>
  181. <delete id="delete">
  182. delete from mall_ad where id = #{value}
  183. </delete>
  184. <delete id="deleteBatch">
  185. delete from mall_ad where id in
  186. <foreach item="id" collection="array" open="(" separator="," close=")">
  187. #{id}
  188. </foreach>
  189. </delete>
  190. </mapper>