GoodsSearchWordsWriteMapper.xml 9.3 KB

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