ApiAdMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. </resultMap>
  17. <select id="queryObject" resultMap="adMap">
  18. select * from mall_ad where id = #{value}
  19. </select>
  20. <select id="queryList" resultMap="adMap">
  21. select * from mall_ad
  22. where 1 = 1 and enabled = 1
  23. <if test="ad_position_id != null and ad_position_id != null">
  24. and ad_position_id = #{ad_position_id}
  25. </if>
  26. <if test="ad_position_ids != null and ad_position_ids.length > 0">
  27. and ad_position_id in
  28. <foreach item="item" collection="ad_position_ids" open="(" separator="," close=")">
  29. #{item}
  30. </foreach>
  31. </if>
  32. <if test="media_types != null">
  33. and media_type in
  34. <foreach item="item" collection="media_types" open="(" separator="," close=")">
  35. #{item}
  36. </foreach>
  37. </if>
  38. <choose>
  39. <when test="sidx != null and sidx.trim() != ''">
  40. order by ${sidx} ${order}
  41. </when>
  42. <otherwise>
  43. order by sort_order
  44. </otherwise>
  45. </choose>
  46. <if test="offset != null and limit != null">
  47. limit #{offset}, #{limit}
  48. </if>
  49. </select>
  50. <select id="queryTotal" resultType="int">
  51. select count(*) from mall_ad
  52. </select>
  53. <insert id="save" parameterType="com.kmall.api.entity.AdVo" useGeneratedKeys="true" keyProperty="id">
  54. insert into mall_ad
  55. (
  56. `ad_position_id`,
  57. `media_type`,
  58. `name`,
  59. `link`,
  60. `image_url`,
  61. `content`,
  62. `end_time`,
  63. `enabled`
  64. )
  65. values
  66. (
  67. #{ad_position_id},
  68. #{media_type},
  69. #{name},
  70. #{link},
  71. #{image_url},
  72. #{content},
  73. #{end_time},
  74. #{enabled}
  75. )
  76. </insert>
  77. <update id="update" parameterType="com.kmall.api.entity.AdVo">
  78. update mall_ad
  79. <set>
  80. <if test="ad_position_id != null">`ad_position_id` = #{adPositionId},</if>
  81. <if test="media_type != null">`media_type` = #{mediaType},</if>
  82. <if test="name != null">`name` = #{name},</if>
  83. <if test="link != null">`link` = #{link},</if>
  84. <if test="image_url != null">`image_url` = #{imageUrl},</if>
  85. <if test="content != null">`content` = #{content},</if>
  86. <if test="end_time != null">`end_time` = #{endTime},</if>
  87. <if test="enabled != null">`enabled` = #{enabled}</if>
  88. </set>
  89. where id = #{id}
  90. </update>
  91. <delete id="delete">
  92. delete from mall_ad where id = #{value}
  93. </delete>
  94. <delete id="deleteBatch">
  95. delete from mall_ad where id in
  96. <foreach item="id" collection="array" open="(" separator="," close=")">
  97. #{id}
  98. </foreach>
  99. </delete>
  100. </mapper>