HpAdvBannerMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.jeeplus.modules.hpadvertisement.mapper.HpAdvBannerMapper">
  4. <sql id="hpAdvBannerColumns">
  5. a.id AS "id",
  6. a.title AS "title",
  7. a.application AS "application",
  8. a.banner_position AS "bannerPosition",
  9. a.sort AS "sort",
  10. a.pic_url AS "picUrl",
  11. a.pic_detail AS "picDetail",
  12. a.position_detail AS "positionDetail",
  13. a.link_flag AS "linkFlag",
  14. a.create_time AS "createTime",
  15. a.create_by AS "createBy.id",
  16. a.update_time AS "updateTime",
  17. a.update_by AS "updateBy.id",
  18. a.end_time AS "endTime",
  19. a.del_flag AS "delFlag"
  20. </sql>
  21. <sql id="hpAdvBannerJoins">
  22. </sql>
  23. <select id="get" resultType="HpAdvBanner" >
  24. SELECT
  25. <include refid="hpAdvBannerColumns"/>
  26. FROM hp_adv_banner a
  27. <include refid="hpAdvBannerJoins"/>
  28. WHERE a.id = #{id}
  29. </select>
  30. <select id="findList" resultType="HpAdvBanner" >
  31. SELECT
  32. <include refid="hpAdvBannerColumns"/>
  33. FROM hp_adv_banner a
  34. <include refid="hpAdvBannerJoins"/>
  35. <where>
  36. ${dataScope}
  37. <if test="title != null and title != ''">
  38. AND a.title LIKE
  39. <if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
  40. <if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
  41. <if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
  42. </if>
  43. <if test="application != null ">
  44. AND a.application = #{application}
  45. </if>
  46. </where>
  47. <choose>
  48. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  49. ORDER BY ${page.orderBy}
  50. </when>
  51. <otherwise>
  52. ORDER BY a.sort ASC, a.update_time DESC
  53. </otherwise>
  54. </choose>
  55. </select>
  56. <select id="findAllList" resultType="HpAdvBanner" >
  57. SELECT
  58. <include refid="hpAdvBannerColumns"/>
  59. FROM hp_adv_banner a
  60. <include refid="hpAdvBannerJoins"/>
  61. <where>
  62. ${dataScope}
  63. </where>
  64. <choose>
  65. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  66. ORDER BY ${page.orderBy}
  67. </when>
  68. <otherwise>
  69. </otherwise>
  70. </choose>
  71. </select>
  72. <insert id="insert" keyProperty="id" useGeneratedKeys="true" parameterType="HpAdvBanner">
  73. INSERT INTO hp_adv_banner(
  74. title,
  75. application,
  76. banner_position,
  77. sort,
  78. pic_url,
  79. pic_detail,
  80. position_detail,
  81. link_flag,
  82. create_time,
  83. create_by,
  84. update_time,
  85. update_by,
  86. end_time,
  87. del_flag
  88. ) VALUES (
  89. #{title},
  90. #{application},
  91. #{bannerPosition},
  92. #{sort},
  93. #{picUrl},
  94. #{picDetail},
  95. #{positionDetail},
  96. #{linkFlag},
  97. #{createTime},
  98. #{createBy.id},
  99. #{updateTime},
  100. #{updateBy.id},
  101. #{endTime},
  102. #{delFlag}
  103. )
  104. </insert>
  105. <update id="update">
  106. UPDATE hp_adv_banner SET
  107. title = #{title},
  108. application = #{application},
  109. banner_position = #{bannerPosition},
  110. sort = #{sort},
  111. pic_url = #{picUrl},
  112. pic_detail = #{picDetail},
  113. position_detail = #{positionDetail},
  114. link_flag = #{linkFlag},
  115. create_time = #{createTime},
  116. update_time = #{updateTime},
  117. update_by = #{updateBy.id},
  118. end_time = #{endTime},
  119. del_flag = #{delFlag}
  120. WHERE id = #{id}
  121. </update>
  122. <!--物理删除-->
  123. <update id="delete">
  124. DELETE FROM hp_adv_banner
  125. WHERE id = #{id}
  126. </update>
  127. <!--逻辑删除-->
  128. <update id="deleteByLogic">
  129. UPDATE hp_adv_banner SET
  130. del_flag = #{DEL_FLAG_DELETE}
  131. WHERE id = #{id}
  132. </update>
  133. <!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
  134. <select id="findUniqueByProperty" resultType="HpAdvBanner" statementType="STATEMENT">
  135. select * FROM hp_adv_banner where ${propertyName} = '${value}'
  136. </select>
  137. <select id="findBannerList" resultType="HpAdvBanner">
  138. SELECT
  139. <include refid="hpAdvBannerColumns"/>
  140. FROM hp_adv_banner a
  141. <include refid="hpAdvBannerJoins"/>
  142. <where>
  143. a.del_flag = 0
  144. and DATE_ADD(a.end_time, INTERVAL 1 DAY) &gt;= now()
  145. <if test="application != null ">
  146. <if test="application == 0">
  147. and (a.application = 0 or a.application = 2)
  148. </if>
  149. <if test="application == 1">
  150. and (a.application = 1 or a.application = 2)
  151. </if>
  152. </if>
  153. </where>
  154. ORDER BY a.sort ASC, a.update_time DESC
  155. </select>
  156. </mapper>