AgreementWriteMapper.xml 8.5 KB

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