AdDao.xml 3.5 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.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. </resultMap>
  15. <select id="queryObject" resultType="com.kmall.admin.entity.AdEntity">
  16. select
  17. id,
  18. ad_position_id,
  19. media_type,
  20. name,
  21. link,
  22. image_url,
  23. content,
  24. end_time,
  25. enabled
  26. from mall_ad
  27. where id = #{id}
  28. </select>
  29. <select id="queryList" resultType="com.kmall.admin.entity.AdEntity">
  30. select
  31. mall_ad.id,
  32. mall_ad.ad_position_id,
  33. mall_ad.media_type,
  34. mall_ad.name,
  35. mall_ad.link,
  36. mall_ad.image_url,
  37. mall_ad.content,
  38. mall_ad.end_time,
  39. mall_ad.enabled,
  40. mall_ad_position.name ad_Position_Name
  41. from mall_ad LEFT JOIN mall_ad_position on mall_ad.ad_position_id = mall_ad_position.id
  42. where 1=1
  43. <if test="name != null and name.trim() != ''">
  44. AND mall_ad.name LIKE concat('%',#{name},'%')
  45. </if>
  46. <choose>
  47. <when test="sidx != null and sidx.trim() != ''">
  48. order by ${sidx} ${order}
  49. </when>
  50. <otherwise>
  51. order by mall_ad.id desc
  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. WHERE 1=1
  61. <if test="name != null and name.trim() != ''">
  62. AND name LIKE concat('%',#{name},'%')
  63. </if>
  64. </select>
  65. <insert id="save" parameterType="com.kmall.admin.entity.AdEntity" useGeneratedKeys="true" keyProperty="id">
  66. insert into mall_ad(
  67. `ad_position_id`,
  68. `media_type`,
  69. `name`,
  70. `link`,
  71. `image_url`,
  72. `content`,
  73. `end_time`,
  74. `enabled`)
  75. values(
  76. #{adPositionId},
  77. #{mediaType},
  78. #{name},
  79. #{link},
  80. #{imageUrl},
  81. #{content},
  82. #{endTime},
  83. #{enabled})
  84. </insert>
  85. <update id="update" parameterType="com.kmall.admin.entity.AdEntity">
  86. update mall_ad
  87. <set>
  88. <if test="adPositionId != null">`ad_position_id` = #{adPositionId},</if>
  89. <if test="mediaType != null">`media_type` = #{mediaType},</if>
  90. <if test="name != null">`name` = #{name},</if>
  91. <if test="link != null">`link` = #{link},</if>
  92. <if test="imageUrl != null">`image_url` = #{imageUrl},</if>
  93. <if test="content != null">`content` = #{content},</if>
  94. <if test="endTime != 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>