AdDao.xml 5.0 KB

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