AdDao.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. where 1=1
  52. <if test="storeId != null and storeId != ''">
  53. AND store_id = #{storeId}
  54. </if>
  55. <if test="merchSn != null and merchSn.trim() != ''">
  56. AND merch_sn = #{merchSn}
  57. </if>
  58. <if test="name != null and name.trim() != ''">
  59. AND mall_ad.name LIKE concat('%',#{name},'%')
  60. </if>
  61. <choose>
  62. <when test="sidx != null and sidx.trim() != ''">
  63. order by ${sidx} ${order}
  64. </when>
  65. <otherwise>
  66. order by mall_ad.id desc
  67. </otherwise>
  68. </choose>
  69. <if test="offset != null and limit != null">
  70. limit #{offset}, #{limit}
  71. </if>
  72. </select>
  73. <select id="queryTotal" resultType="int">
  74. select count(*) from mall_ad
  75. WHERE 1=1
  76. <if test="storeId != null and storeId != ''">
  77. AND store_id = #{storeId}
  78. </if>
  79. <if test="merchSn != null and merchSn.trim() != ''">
  80. AND merch_sn = #{merchSn}
  81. </if>
  82. <if test="name != null and name.trim() != ''">
  83. AND name LIKE concat('%',#{name},'%')
  84. </if>
  85. </select>
  86. <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
  87. insert into mall_ad(
  88. `ad_position_id`,
  89. `media_type`,
  90. `name`,
  91. `store_id`,
  92. `merch_sn`,
  93. `link`,
  94. `image_url`,
  95. `sort_order`,
  96. `content`,
  97. `end_time`,
  98. `enabled`)
  99. values(
  100. #{adPositionId},
  101. #{mediaType},
  102. #{name},
  103. #{storeId},
  104. #{merchSn},
  105. #{link},
  106. #{imageUrl},
  107. #{sortOrder},
  108. #{content},
  109. #{endTime},
  110. #{enabled})
  111. </insert>
  112. <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
  113. update mall_ad
  114. <set>
  115. <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
  116. <if test="mediaType != null">`media_type` = #{mediaType},</if>
  117. <if test="name != null">`name` = #{name},</if>
  118. <if test="storeId != null">`store_id` = #{storeId}, </if>
  119. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  120. <if test="link != null">`link` = #{link},</if>
  121. <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
  122. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  123. <if test="content != null">`content` = #{content},</if>
  124. <if test="endTime != null">`end_time` = #{endTime},</if>
  125. <if test="enabled != null">`enabled` = #{enabled}</if>
  126. </set>
  127. where id = #{id}
  128. </update>
  129. <delete id="delete">
  130. delete from mall_ad where id = #{value}
  131. </delete>
  132. <delete id="deleteBatch">
  133. delete from mall_ad where id in
  134. <foreach item="id" collection="array" open="(" separator="," close=")">
  135. #{id}
  136. </foreach>
  137. </delete>
  138. </mapper>