ApiAdMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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
  60. </select>
  61. <insert id="save" parameterType="com.kmall.api.entity.AdVo" useGeneratedKeys="true" keyProperty="id">
  62. insert into mall_ad
  63. (
  64. `ad_position_id`,
  65. `media_type`,
  66. `name`,
  67. `link`,
  68. `image_url`,
  69. `content`,
  70. `end_time`,
  71. `enabled`
  72. )
  73. values
  74. (
  75. #{ad_position_id},
  76. #{media_type},
  77. #{name},
  78. #{link},
  79. #{image_url},
  80. #{content},
  81. #{end_time},
  82. #{enabled}
  83. )
  84. </insert>
  85. <update id="update" parameterType="com.kmall.api.entity.AdVo">
  86. update mall_ad
  87. <set>
  88. <if test="ad_position_id != null">`ad_position_id` = #{adPositionId},</if>
  89. <if test="media_type != null">`media_type` = #{mediaType},</if>
  90. <if test="name != null">`name` = #{name},</if>
  91. <if test="link != null">`link` = #{link},</if>
  92. <if test="image_url != null">`image_url` = #{imageUrl},</if>
  93. <if test="content != null">`content` = #{content},</if>
  94. <if test="end_time != null">`end_time` = #{endTime},</if>
  95. <if test="enabled != null">`enabled` = #{enabled}</if>
  96. </set>
  97. where id = #{id}
  98. </update>
  99. <delete id="delete">
  100. delete from mall_ad where id = #{value}
  101. </delete>
  102. <delete id="deleteBatch">
  103. delete from mall_ad where id in
  104. <foreach item="id" collection="array" open="(" separator="," close=")">
  105. #{id}
  106. </foreach>
  107. </delete>
  108. </mapper>