BannerMapper.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.BannerMapper">
  5. <resultMap id="BannerDtoResultMap" type="com.zhyc.xps.sys.dto.BannerDto" >
  6. <result column="banner_id" property="bannerId" jdbcType="BIGINT" /><!--Banner ID-->
  7. <result column="banner_title" property="bannerTitle" jdbcType="VARCHAR"/>
  8. <result column="banner_type_id" property="bannerTypeId" jdbcType="BIGINT" />
  9. <result column="banner_type_title" property="bannerTypeTitle" jdbcType="VARCHAR"/>
  10. <result column="order" property="order" jdbcType="BIGINT" />
  11. <result column="is_visible" property="isVisible" jdbcType="BIGINT" />
  12. <result column="url" property="url" jdbcType="VARCHAR"/>
  13. <result column="image_path" property="imagePath" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <sql id="BannerDto_Cols">
  16. A.banner_id,
  17. A.banner_title,
  18. A.banner_type_id,
  19. B.banner_type_title,
  20. A.order,
  21. A.is_visible,
  22. A.url,
  23. A.image_path
  24. </sql>
  25. <!--基于ID查询-->
  26. <select id="getById" resultMap="BannerDtoResultMap">
  27. SELECT
  28. <include refid="BannerDto_Cols"/>
  29. FROM banner AS A
  30. LEFT JOIN banner_type AS B ON (A.banner_type_id = B.banner_type_id)
  31. WHERE 1 = 1 AND A.deleted_flag = 0
  32. <if test="bannerId !=null">
  33. AND A.banner_id = #{bannerId ,jdbcType=BIGINT}
  34. </if>
  35. </select>
  36. <!--列表查询-->
  37. <select id="getByList" resultMap="BannerDtoResultMap" parameterType="java.util.Map">
  38. SELECT
  39. <include refid="BannerDto_Cols"/>
  40. FROM banner AS A
  41. LEFT JOIN banner_type AS B ON (A.banner_type_id = B.banner_type_id)
  42. WHERE 1 = 1 AND A.deleted_flag = 0
  43. <if test="bannerId !=null">
  44. AND A.banner_id = #{bannerId ,jdbcType=BIGINT}
  45. </if>
  46. <if test="bannerTypeId != null">
  47. AND A.banner_type_id = #{bannerTypeId ,jdbcType=BIGINT}
  48. </if>
  49. <if test="isVisible != null">
  50. AND A.is_visible = #{isVisible ,jdbcType=BIGINT}
  51. </if>
  52. ORDER BY A.banner_id ASC
  53. </select>
  54. <!--分页查询-->
  55. <select id="getByPage" resultMap="BannerDtoResultMap" parameterType="java.util.Map">
  56. SELECT
  57. <include refid="BannerDto_Cols"/>
  58. FROM banner AS A
  59. LEFT JOIN banner_type AS B ON (A.banner_type_id = B.banner_type_id)
  60. WHERE 1 = 1 AND A.deleted_flag = 0
  61. <if test="bannerId !=null">
  62. AND A.banner_id = #{bannerId ,jdbcType=BIGINT}
  63. </if>
  64. <if test="bannerTypeId != null">
  65. AND A.banner_type_id = #{bannerTypeId ,jdbcType=BIGINT}
  66. </if>
  67. <if test="isVisible != null">
  68. AND A.is_visible = #{isVisible ,jdbcType=BIGINT}
  69. </if>
  70. ORDER BY A.banner_id ASC
  71. </select>
  72. <!--新增-->
  73. <insert id="create" parameterType="com.zhyc.xps.sys.entity.Banner" keyProperty="bannerId">
  74. INSERT INTO banner
  75. <trim prefix="(" suffix=")" suffixOverrides=",">
  76. <if test="bannerId != null">
  77. banner_id,
  78. </if>
  79. <if test="bannerTypeId != null">
  80. banner_type_id,
  81. </if>
  82. <if test="bannerTitle != null and bannerTitle!=''">
  83. banner_title,
  84. </if>
  85. <if test="imagePath != null and imagePath != ''">
  86. image_path,
  87. </if>
  88. <if test="url != null and url != ''">
  89. url,
  90. </if>
  91. <if test="order != null">
  92. order,
  93. </if>
  94. <if test="isVisible != null">
  95. is_visible,
  96. </if>
  97. <if test="createdBy != null">
  98. created_by,
  99. </if>
  100. <if test="createdAt != null">
  101. created_at,
  102. </if>
  103. </trim>
  104. <trim prefix="values (" suffix=")" suffixOverrides=",">
  105. <if test="bannerId != null">
  106. #{bannerId ,jdbcType=BIGINT},
  107. </if>
  108. <if test="bannerTypeId != null">
  109. #{bannerTypeId ,jdbcType=BIGINT},
  110. </if>
  111. <if test="bannerTitle != null and bannerTitle!=''">
  112. #{bannerTitle ,jdbcType=VARCHAR},
  113. </if>
  114. <if test="imagePath != null and imagePath != ''">
  115. #{imagePath,jdbcType=VARCHAR},
  116. </if>
  117. <if test="url != null and url != ''">
  118. #{url ,jdbcType=VARCHAR},
  119. </if>
  120. <if test="order != null">
  121. #{order ,jdbcType=BIGINT},
  122. </if>
  123. <if test="isVisible != null">
  124. #{isVisible ,jdbcType=BIGINT},
  125. </if>
  126. <if test="createdBy != null">
  127. #{createdBy ,jdbcType=BIGINT},
  128. </if>
  129. <if test="createdAt != null">
  130. #{createdAt ,jdbcType=TIMESTAMP},
  131. </if>
  132. </trim>
  133. </insert>
  134. <!--更新-->
  135. <update id="update" parameterType="com.zhyc.xps.sys.entity.Banner">
  136. UPDATE banner
  137. <trim suffixOverrides=",">
  138. <set>
  139. <if test="bannerTypeId != null">
  140. banner_type_id = #{bannerTypeId ,jdbcType=BIGINT},
  141. </if>
  142. <if test="bannerTitle != null">
  143. banner_title =#{bannerTitle ,jdbcType=VARCHAR},
  144. </if>
  145. <if test="imagePath != null and imagePath != ''">
  146. image_path = #{imagePath ,jdbcType=VARCHAR},
  147. </if>
  148. <if test="url != null and url != ''">
  149. url = #{url ,jdbcType=VARCHAR},
  150. </if>
  151. <if test="order != null">
  152. order = #{order ,jdbcType=BIGINT},
  153. </if>
  154. <if test="isVisible != null">
  155. is_visible = #{isVisible ,jdbcType=BIGINT},
  156. </if>
  157. <if test="updatedBy != null">
  158. updated_by = #{updatedBy ,jdbcType=BIGINT},
  159. </if>
  160. <if test="updatedAt != null">
  161. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  162. </if>
  163. </set>
  164. </trim>
  165. WHERE 1 = 1
  166. <if test="bannerId != null">
  167. AND banner_id = #{bannerId ,jdbcType=BIGINT}
  168. </if>
  169. </update>
  170. <!--删除 -->
  171. <update id="delete" parameterType="java.util.Map">
  172. UPDATE banner
  173. <trim suffixOverrides=",">
  174. <set>
  175. <if test="deletedBy != null">
  176. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  177. </if>
  178. <if test="deletedAt != null">
  179. deleted_at = #{deletedAt ,jdbcType=DATE},
  180. </if>
  181. <if test="deletedFlag != null">
  182. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  183. </if>
  184. </set>
  185. </trim>
  186. WHERE 1 = 1 AND deleted_flag = 0
  187. <if test="bannerId != null">
  188. AND banner_id = #{bannerId ,jdbcType=BIGINT}
  189. </if>
  190. </update>
  191. </mapper>