1
0

AdDao.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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="link" column="link"/>
  10. <result property="imageUrl" column="image_url"/>
  11. <result property="content" column="content"/>
  12. <result property="endTime" column="end_time"/>
  13. <result property="enabled" column="enabled"/>
  14. <result property="sortOrder" column="sort_order"/>
  15. </resultMap>
  16. <select id="queryObject" resultType="com.kmall.admin.entity.AdEntity">
  17. select
  18. id,
  19. ad_position_id,
  20. media_type,
  21. name,
  22. link,
  23. image_url,
  24. sort_order,
  25. content,
  26. end_time,
  27. enabled
  28. from mall_ad
  29. where id = #{id}
  30. </select>
  31. <select id="queryList" resultType="com.kmall.admin.entity.AdEntity">
  32. select
  33. mall_ad.id,
  34. mall_ad.ad_position_id,
  35. mall_ad.media_type,
  36. mall_ad.name,
  37. mall_ad.link,
  38. mall_ad.image_url,
  39. mall_ad.sort_order,
  40. mall_ad.content,
  41. mall_ad.end_time,
  42. mall_ad.enabled,
  43. mall_ad_position.name ad_Position_Name
  44. from mall_ad LEFT JOIN mall_ad_position on mall_ad.ad_position_id = mall_ad_position.id
  45. where 1=1
  46. <if test="name != null and name.trim() != ''">
  47. AND mall_ad.name LIKE concat('%',#{name},'%')
  48. </if>
  49. <choose>
  50. <when test="sidx != null and sidx.trim() != ''">
  51. order by ${sidx} ${order}
  52. </when>
  53. <otherwise>
  54. order by mall_ad.id desc
  55. </otherwise>
  56. </choose>
  57. <if test="offset != null and limit != null">
  58. limit #{offset}, #{limit}
  59. </if>
  60. </select>
  61. <select id="queryTotal" resultType="int">
  62. select count(*) from mall_ad
  63. WHERE 1=1
  64. <if test="name != null and name.trim() != ''">
  65. AND name LIKE concat('%',#{name},'%')
  66. </if>
  67. </select>
  68. <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
  69. insert into mall_ad(
  70. `ad_position_id`,
  71. `media_type`,
  72. `name`,
  73. `link`,
  74. `image_url`,
  75. `sort_order`,
  76. `content`,
  77. `end_time`,
  78. `enabled`)
  79. values(
  80. #{adPositionId},
  81. #{mediaType},
  82. #{name},
  83. #{link},
  84. #{imageUrl},
  85. #{sortOrder},
  86. #{content},
  87. #{endTime},
  88. #{enabled})
  89. </insert>
  90. <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
  91. update mall_ad
  92. <set>
  93. <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
  94. <if test="mediaType != null">`media_type` = #{mediaType},</if>
  95. <if test="name != null">`name` = #{name},</if>
  96. <if test="link != null">`link` = #{link},</if>
  97. <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
  98. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  99. <if test="content != null">`content` = #{content},</if>
  100. <if test="endTime != null">`end_time` = #{endTime},</if>
  101. <if test="enabled != null">`enabled` = #{enabled}</if>
  102. </set>
  103. where id = #{id}
  104. </update>
  105. <delete id="delete">
  106. delete from mall_ad where id = #{value}
  107. </delete>
  108. <delete id="deleteBatch">
  109. delete from mall_ad where id in
  110. <foreach item="id" collection="array" open="(" separator="," close=")">
  111. #{id}
  112. </foreach>
  113. </delete>
  114. </mapper>