1
0

ApiAdMapper.xml 3.5 KB

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