ApiAdMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.api.dao.ApiAdMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.AdVo" id="adMap">
  6. <result property="id" column="id"/>
  7. <result property="ad_position_id" column="adPositionId"/>
  8. <result property="media_type" column="mediaType"/>
  9. <result property="name" column="name"/>
  10. <result property="link" column="link"/>
  11. <result property="image_url" column="imageUrl"/>
  12. <result property="content" column="content"/>
  13. <result property="end_time" column="endTime"/>
  14. <result property="enabled" column="enabled"/>
  15. <result property="sortOrder" column="sort_order"/>
  16. <result property="merchSn" column="mersh_sn"/>
  17. <result property="storeId" column="store_id"/>
  18. </resultMap>
  19. <select id="queryObject" resultMap="adMap">
  20. select * from mall_ad where id = #{value}
  21. </select>
  22. <select id="queryList" resultMap="adMap">
  23. select * from mall_ad
  24. where 1 = 1 and enabled = 1
  25. <if test="ad_position_id != null and ad_position_id != null">
  26. and ad_position_id = #{ad_position_id}
  27. </if>
  28. <if test="storeId != null and storeId != null">
  29. and store_id = #{storeId}
  30. </if>
  31. <if test="merchSn != null and merchSn != null">
  32. and mersh_sn = #{merchSn}
  33. </if>
  34. <if test="ad_position_ids != null and ad_position_ids.length > 0">
  35. and ad_position_id in
  36. <foreach item="item" collection="ad_position_ids" open="(" separator="," close=")">
  37. #{item}
  38. </foreach>
  39. </if>
  40. <if test="media_types != null">
  41. and media_type in
  42. <foreach item="item" collection="media_types" open="(" separator="," close=")">
  43. #{item}
  44. </foreach>
  45. </if>
  46. <choose>
  47. <when test="sidx != null and sidx.trim() != ''">
  48. order by ${sidx} ${order}
  49. </when>
  50. <otherwise>
  51. order by sort_order
  52. </otherwise>
  53. </choose>
  54. <if test="offset != null and limit != null">
  55. limit #{offset}, #{limit}
  56. </if>
  57. </select>
  58. <select id="queryTotal" resultType="int">
  59. select count(*) from mall_ad where 1 = 1 and enabled = 1
  60. <if test="ad_position_id != null and ad_position_id != null">
  61. and ad_position_id = #{ad_position_id}
  62. </if>
  63. <if test="storeId != null and storeId != null">
  64. and store_id = #{storeId}
  65. </if>
  66. <if test="merchSn != null and merchSn != null">
  67. and mersh_sn = #{merchSn}
  68. </if>
  69. <if test="ad_position_ids != null and ad_position_ids.length > 0">
  70. and ad_position_id in
  71. <foreach item="item" collection="ad_position_ids" open="(" separator="," close=")">
  72. #{item}
  73. </foreach>
  74. </if>
  75. <if test="media_types != null">
  76. and media_type in
  77. <foreach item="item" collection="media_types" open="(" separator="," close=")">
  78. #{item}
  79. </foreach>
  80. </if>
  81. </select>
  82. <insert id="save" parameterType="com.kmall.api.entity.AdVo" useGeneratedKeys="true" keyProperty="id">
  83. insert into mall_ad
  84. (
  85. `ad_position_id`,
  86. `media_type`,
  87. `name`,
  88. `link`,
  89. `image_url`,
  90. `content`,
  91. `end_time`,
  92. `enabled`
  93. )
  94. values
  95. (
  96. #{ad_position_id},
  97. #{media_type},
  98. #{name},
  99. #{link},
  100. #{image_url},
  101. #{content},
  102. #{end_time},
  103. #{enabled}
  104. )
  105. </insert>
  106. <update id="update" parameterType="com.kmall.api.entity.AdVo">
  107. update mall_ad
  108. <set>
  109. <if test="ad_position_id != null">`ad_position_id` = #{adPositionId},</if>
  110. <if test="media_type != null">`media_type` = #{mediaType},</if>
  111. <if test="name != null">`name` = #{name},</if>
  112. <if test="link != null">`link` = #{link},</if>
  113. <if test="image_url != null">`image_url` = #{imageUrl},</if>
  114. <if test="content != null">`content` = #{content},</if>
  115. <if test="end_time != null">`end_time` = #{endTime},</if>
  116. <if test="enabled != null">`enabled` = #{enabled}</if>
  117. </set>
  118. where id = #{id}
  119. </update>
  120. <delete id="delete">
  121. delete from mall_ad where id = #{value}
  122. </delete>
  123. <delete id="deleteBatch">
  124. delete from mall_ad where id in
  125. <foreach item="id" collection="array" open="(" separator="," close=")">
  126. #{id}
  127. </foreach>
  128. </delete>
  129. </mapper>