NavigationWriteMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.slodon.b2b2c.dao.write.system.NavigationWriteMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.system.pojo.Navigation">
  5. <id column="nav_id" property="navId" />
  6. <result column="web_site" property="webSite" />
  7. <result column="nav_name" property="navName" />
  8. <result column="sort" property="sort" />
  9. <result column="is_show" property="isShow" />
  10. <result column="data" property="data" />
  11. <result column="create_time" property="createTime" />
  12. </resultMap>
  13. <!--除主键外的所有字段,用于插入操作-->
  14. <sql id="columns">
  15. <trim suffixOverrides=",">
  16. <if test="webSite != null">
  17. `web_site`,
  18. </if>
  19. <if test="navName != null">
  20. `nav_name`,
  21. </if>
  22. <if test="sort != null">
  23. `sort`,
  24. </if>
  25. <if test="isShow != null">
  26. `is_show`,
  27. </if>
  28. <if test="data != null">
  29. `data`,
  30. </if>
  31. <if test="createTime != null">
  32. `create_time`,
  33. </if>
  34. </trim>
  35. </sql>
  36. <!--按照主键值进行操作-->
  37. <sql id="pkWhere">
  38. WHERE `nav_id` = #{primaryKey}
  39. </sql>
  40. <!--操作条件-->
  41. <sql id="whereCondition">
  42. <if test="example != null">
  43. <trim prefix="WHERE" prefixOverrides="AND|OR">
  44. <if test="example.navIdNotEquals != null">
  45. AND `nav_id` != #{example.navIdNotEquals}
  46. </if>
  47. <if test="example.navIdIn != null">
  48. AND `nav_id` in (${example.navIdIn})
  49. </if>
  50. <if test="example.webSite != null">
  51. AND `web_site` = #{example.webSite}
  52. </if>
  53. <if test="example.navName != null">
  54. AND `nav_name` = #{example.navName}
  55. </if>
  56. <if test="example.navNameLike != null">
  57. AND `nav_name` like concat('%',#{example.navNameLike},'%')
  58. </if>
  59. <if test="example.sort != null">
  60. AND `sort` = #{example.sort}
  61. </if>
  62. <if test="example.isShow != null">
  63. AND `is_show` = #{example.isShow}
  64. </if>
  65. <if test="example.data != null">
  66. AND `data` = #{example.data}
  67. </if>
  68. </trim>
  69. </if>
  70. </sql>
  71. <!--排序条件-->
  72. <sql id="orderBy">
  73. ORDER BY `sort` DESC ,`create_time` DESC
  74. </sql>
  75. <sql id="orderByOther">
  76. order by ${example.orderBy}
  77. </sql>
  78. <!--分组条件-->
  79. <sql id="groupBy">
  80. group by ${example.groupBy}
  81. </sql>
  82. <!--分页条件-->
  83. <sql id="limit">
  84. <if test="size != null and size &gt; 0">
  85. limit #{startRow},#{size}
  86. </if>
  87. </sql>
  88. <!--查询符合条件的记录数-->
  89. <select id="countByExample" parameterType="com.slodon.b2b2c.system.example.NavigationExample" resultType="java.lang.Integer">
  90. SELECT
  91. COUNT(*)
  92. FROM `sys_pc_navigation`
  93. <include refid="whereCondition" />
  94. </select>
  95. <!--根据主键查询记录-->
  96. <select id="getByPrimaryKey" resultMap="resultMap">
  97. SELECT
  98. *
  99. FROM `sys_pc_navigation`
  100. <include refid="pkWhere" />
  101. </select>
  102. <!--查询符合条件的记录(所有字段)-->
  103. <select id="listByExample" resultMap="resultMap">
  104. SELECT
  105. *
  106. FROM `sys_pc_navigation`
  107. <include refid="whereCondition" />
  108. <if test="example.groupBy != null">
  109. <include refid="groupBy" />
  110. </if>
  111. <choose>
  112. <when test="example.orderBy != null">
  113. <include refid="orderByOther" />
  114. </when>
  115. <otherwise>
  116. <include refid="orderBy" />
  117. </otherwise>
  118. </choose>
  119. </select>
  120. <!--分页查询符合条件的记录(所有字段)-->
  121. <select id="listPageByExample" resultMap="resultMap">
  122. SELECT
  123. *
  124. FROM `sys_pc_navigation`
  125. <include refid="whereCondition" />
  126. <if test="example.groupBy != null">
  127. <include refid="groupBy" />
  128. </if>
  129. <choose>
  130. <when test="example.orderBy != null">
  131. <include refid="orderByOther" />
  132. </when>
  133. <otherwise>
  134. <include refid="orderBy" />
  135. </otherwise>
  136. </choose>
  137. <include refid="limit" />
  138. </select>
  139. <!--查询符合条件的记录(指定字段)-->
  140. <select id="listFieldsByExample" resultMap="resultMap">
  141. SELECT
  142. ${fields}
  143. FROM `sys_pc_navigation`
  144. <include refid="whereCondition" />
  145. <if test="example.groupBy != null">
  146. <include refid="groupBy" />
  147. </if>
  148. <choose>
  149. <when test="example.orderBy != null">
  150. <include refid="orderByOther" />
  151. </when>
  152. <otherwise>
  153. <include refid="orderBy" />
  154. </otherwise>
  155. </choose>
  156. </select>
  157. <!--分页查询符合条件的记录(指定字段)-->
  158. <select id="listFieldsPageByExample" resultMap="resultMap">
  159. SELECT
  160. ${fields}
  161. FROM `sys_pc_navigation`
  162. <include refid="whereCondition" />
  163. <if test="example.groupBy != null">
  164. <include refid="groupBy" />
  165. </if>
  166. <choose>
  167. <when test="example.orderBy != null">
  168. <include refid="orderByOther" />
  169. </when>
  170. <otherwise>
  171. <include refid="orderBy" />
  172. </otherwise>
  173. </choose>
  174. <include refid="limit" />
  175. </select>
  176. <!--根据条件删除记录,可多条删除-->
  177. <delete id="deleteByExample">
  178. DELETE FROM `sys_pc_navigation`
  179. <include refid="whereCondition" />
  180. </delete>
  181. <!--根据主键删除记录-->
  182. <delete id="deleteByPrimaryKey">
  183. DELETE FROM `sys_pc_navigation`
  184. <include refid="pkWhere" />
  185. </delete>
  186. <!--插入一条记录-->
  187. <insert id="insert" keyColumn="nav_id" keyProperty="navId" parameterType="com.slodon.b2b2c.system.pojo.Navigation" useGeneratedKeys="true">
  188. INSERT INTO `sys_pc_navigation`(
  189. <include refid="columns" />
  190. )
  191. VALUES(
  192. <trim suffixOverrides=",">
  193. <if test="webSite != null">
  194. #{webSite},
  195. </if>
  196. <if test="navName != null">
  197. #{navName},
  198. </if>
  199. <if test="sort != null">
  200. #{sort},
  201. </if>
  202. <if test="isShow != null">
  203. #{isShow},
  204. </if>
  205. <if test="data != null">
  206. #{data},
  207. </if>
  208. <if test="createTime != null">
  209. #{createTime},
  210. </if>
  211. </trim>
  212. )
  213. </insert>
  214. <!--按条件更新记录中不为空的字段-->
  215. <update id="updateByExampleSelective">
  216. UPDATE `sys_pc_navigation`
  217. <trim prefix="SET" suffixOverrides=",">
  218. <if test="record.webSite != null">
  219. `web_site` = #{record.webSite},
  220. </if>
  221. <if test="record.navName != null">
  222. `nav_name` = #{record.navName},
  223. </if>
  224. <if test="record.sort != null">
  225. `sort` = #{record.sort},
  226. </if>
  227. <if test="record.isShow != null">
  228. `is_show` = #{record.isShow},
  229. </if>
  230. <if test="record.data != null">
  231. `data` = #{record.data},
  232. </if>
  233. </trim>
  234. <include refid="whereCondition" />
  235. </update>
  236. <!--按照主键更新记录中不为空的字段-->
  237. <update id="updateByPrimaryKeySelective">
  238. UPDATE `sys_pc_navigation`
  239. <trim prefix="SET" suffixOverrides=",">
  240. <if test="webSite != null">
  241. `web_site` = #{webSite},
  242. </if>
  243. <if test="navName != null">
  244. `nav_name` = #{navName},
  245. </if>
  246. <if test="sort != null">
  247. `sort` = #{sort},
  248. </if>
  249. <if test="isShow != null">
  250. `is_show` = #{isShow},
  251. </if>
  252. <if test="data != null">
  253. `data` = #{data},
  254. </if>
  255. </trim>
  256. WHERE `nav_id` = #{navId}
  257. </update>
  258. </mapper>