CmmeProductMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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.cmme.modules.product.dao.CmmeProductDao">
  4. <sql id="cmmeProductColumns">
  5. a.productID AS "id",
  6. a.productID AS "productID",
  7. a.brandID AS "brandID",
  8. a.bigTypeID AS "bigTypeID",
  9. a.smallTypeID AS "smallTypeID",
  10. a.feedbackType AS "feedbackType",
  11. a.shopCode AS "shopCode",
  12. a.shopID AS "shopID",
  13. a.name AS "name",
  14. a.searchKey AS "searchKey",
  15. a.normalPrice AS "normalPrice",
  16. a.price0 AS "price0",
  17. a.price0Text AS "price0Text",
  18. a.price0TextFlag AS "price0TextFlag",
  19. a.price1 AS "price1",
  20. a.price1Text AS "price1Text",
  21. a.priceFlag AS "priceFlag",
  22. a.stock AS "stock",
  23. a.mainImage AS "mainImage",
  24. a.addTime AS "addTime",
  25. a.updateTime AS "updateTime",
  26. a.beforeValidFlag AS "beforeValidFlag",
  27. a.validFlag AS "validFlag",
  28. a.favoriteTimes AS "favoriteTimes",
  29. a.commentScore AS "commentScore",
  30. a.commentTimes AS "commentTimes",
  31. a.sortIndex AS "sortIndex",
  32. a.productCode AS "productCode",
  33. a.unit AS "unit",
  34. a.serviceNumber AS "serviceNumber",
  35. a.maxBuyNumber AS "maxBuyNumber",
  36. a.minBuyNumber AS "minBuyNumber",
  37. a.packageCount AS "packageCount",
  38. a.byFlag AS "byFlag",
  39. a.step AS "step",
  40. a.freePostFlag AS "freePostFlag",
  41. a.precisehKey AS "precisehKey",
  42. a.docBoost AS "docBoost",
  43. cs.name AS "shopName",
  44. cpd.detailInfo AS "detailInfo",
  45. cpd.detailInfoTxt AS "detailInfoTxt",
  46. cpd.seoTitle AS "seoTitle",
  47. cpd.seoKeyword AS "seoKeyword",
  48. cpd.seoDes AS "seoDes",
  49. cpd.technicalParameter AS "technicalParameter",
  50. cpd.expertOpinion AS "expertOpinion",
  51. cpd.clinicalResult AS "clinicalResult",
  52. cpd.video AS "video"
  53. </sql>
  54. <sql id="cmmeProductJoins">
  55. LEFT JOIN cmme_shop cs ON cs.shopID = a.shopID
  56. LEFT JOIN cmme_productdetailinfo cpd ON cpd.productID = a.productID
  57. </sql>
  58. <select id="get" resultType="CmmeProduct">
  59. SELECT
  60. <include refid="cmmeProductColumns"/>
  61. FROM cmme_product a
  62. <include refid="cmmeProductJoins"/>
  63. WHERE a.productID = #{id}
  64. </select>
  65. <select id="findList" resultType="CmmeProduct">
  66. SELECT
  67. <include refid="cmmeProductColumns"/>
  68. FROM cmme_product a
  69. <include refid="cmmeProductJoins"/>
  70. <where>
  71. <if test="shopName != null and shopName != ''">
  72. AND cs.name LIKE concat('%',#{shopName},'%')
  73. </if>
  74. <if test="productID != null and productID != ''">
  75. AND a.productID = #{productID}
  76. </if>
  77. <if test="bigTypeID != null and bigTypeID != ''">
  78. AND a.bigTypeID = #{bigTypeID}
  79. </if>
  80. <if test="smallTypeID != null and smallTypeID != ''">
  81. AND a.smallTypeID = #{smallTypeID}
  82. </if>
  83. <if test="shopCode != null and shopCode != ''">
  84. AND a.shopCode = #{shopCode}
  85. </if>
  86. <if test="name != null and name != ''">
  87. AND a.name LIKE
  88. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  89. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  90. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  91. </if>
  92. <if test="validFlag != null and validFlag != ''">
  93. AND a.validFlag = #{validFlag}
  94. </if>
  95. </where>
  96. <choose>
  97. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  98. ORDER BY ${page.orderBy}
  99. </when>
  100. <otherwise>
  101. ORDER BY a.validFlag ASC ,a.addTime DESC
  102. </otherwise>
  103. </choose>
  104. </select>
  105. <select id="findAllList" resultType="CmmeProduct">
  106. SELECT
  107. <include refid="cmmeProductColumns"/>
  108. FROM cmme_product a
  109. <include refid="cmmeProductJoins"/>
  110. <where>
  111. </where>
  112. <choose>
  113. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  114. ORDER BY ${page.orderBy}
  115. </when>
  116. <otherwise>
  117. </otherwise>
  118. </choose>
  119. </select>
  120. <insert id="insert" parameterType="CmmeProduct" keyProperty="id" useGeneratedKeys="true">
  121. INSERT INTO cmme_product(
  122. brandID,
  123. bigTypeID,
  124. smallTypeID,
  125. feedbackType,
  126. shopCode,
  127. shopID,
  128. name,
  129. searchKey,
  130. normalPrice,
  131. price0,
  132. price0Text,
  133. price0TextFlag,
  134. price1,
  135. price1Text,
  136. priceFlag,
  137. stock,
  138. mainImage,
  139. addTime,
  140. updateTime,
  141. beforeValidFlag,
  142. validFlag,
  143. favoriteTimes,
  144. commentScore,
  145. commentTimes,
  146. sortIndex,
  147. productCode,
  148. unit,
  149. serviceNumber,
  150. maxBuyNumber,
  151. minBuyNumber,
  152. packageCount,
  153. byFlag,
  154. step,
  155. freePostFlag,
  156. precisehKey,
  157. docBoost
  158. ) VALUES (
  159. #{brandID},
  160. #{bigTypeID},
  161. #{smallTypeID},
  162. #{feedbackType},
  163. #{shopCode},
  164. #{shopID},
  165. #{name},
  166. #{searchKey},
  167. #{normalPrice},
  168. #{price0},
  169. #{price0Text},
  170. #{price0TextFlag},
  171. #{price1},
  172. #{price1Text},
  173. #{priceFlag},
  174. #{stock},
  175. #{mainImage},
  176. #{addTime},
  177. #{updateTime},
  178. #{beforeValidFlag},
  179. #{validFlag},
  180. #{favoriteTimes},
  181. #{commentScore},
  182. #{commentTimes},
  183. #{sortIndex},
  184. #{productCode},
  185. #{unit},
  186. #{serviceNumber},
  187. #{maxBuyNumber},
  188. #{minBuyNumber},
  189. #{packageCount},
  190. #{byFlag},
  191. #{step},
  192. #{freePostFlag},
  193. #{precisehKey},
  194. #{docBoost}
  195. )
  196. </insert>
  197. <update id="update">
  198. UPDATE cmme_product SET
  199. <if test="brandID != null and brandID != ''">
  200. brandID = #{brandID},
  201. </if>
  202. <if test="bigTypeID != null and bigTypeID != ''">
  203. bigTypeID = #{bigTypeID},
  204. </if>
  205. <if test="smallTypeID != null and smallTypeID != ''">
  206. smallTypeID = #{smallTypeID},
  207. </if>
  208. <if test="feedbackType != null and feedbackType != ''">
  209. feedbackType = #{feedbackType},
  210. </if>
  211. <if test="shopCode != null and shopCode != ''">
  212. shopCode = #{shopCode},
  213. </if>
  214. <if test="shopID != null and shopID != ''">
  215. shopID = #{shopID},
  216. </if>
  217. <if test="name != null and name != ''">
  218. name = #{name},
  219. </if>
  220. <if test="searchKey != null and searchKey != ''">
  221. searchKey = #{searchKey},
  222. </if>
  223. <if test="normalPrice != null and normalPrice != ''">
  224. normalPrice = #{normalPrice},
  225. </if>
  226. <if test="price0 != null and price0 != ''">
  227. price0 = #{price0},
  228. </if>
  229. <if test="price0Text != null and price0Text != ''">
  230. price0Text = #{price0Text},
  231. </if>
  232. <if test="price0TextFlag != null and price0TextFlag != ''">
  233. price0TextFlag = #{price0TextFlag},
  234. </if>
  235. <if test="price1 != null and price1 != ''">
  236. price1 = #{price1},
  237. </if>
  238. <if test="price1Text != null and price1Text != ''">
  239. price1Text = #{price1Text},
  240. </if>
  241. <if test="priceFlag != null and priceFlag != ''">
  242. priceFlag = #{priceFlag},
  243. </if>
  244. <if test="stock != null and stock != ''">
  245. stock = #{stock},
  246. </if>
  247. <if test="mainImage != null and mainImage != ''">
  248. mainImage = #{mainImage},
  249. </if>
  250. <if test="addTime != null and addTime != ''">
  251. addTime = #{addTime},
  252. </if>
  253. <if test="updateTime != null and updateTime != ''">
  254. updateTime = #{updateTime},
  255. </if>
  256. <if test="beforeValidFlag != null and beforeValidFlag != ''">
  257. beforeValidFlag = #{beforeValidFlag},
  258. </if>
  259. <if test="validFlag != null and validFlag != ''">
  260. validFlag = #{validFlag},
  261. </if>
  262. <if test="favoriteTimes != null and favoriteTimes != ''">
  263. favoriteTimes = #{favoriteTimes},
  264. </if>
  265. <if test="commentScore != null and commentScore != ''">
  266. commentScore = #{commentScore},
  267. </if>
  268. <if test="commentTimes != null and commentTimes != ''">
  269. commentTimes = #{commentTimes},
  270. </if>
  271. <if test="sortIndex != null and sortIndex != ''">
  272. sortIndex = #{sortIndex},
  273. </if>
  274. <if test="productCode != null and productCode != ''">
  275. productCode = #{productCode},
  276. </if>
  277. <if test="unit != null and unit != ''">
  278. unit = #{unit},
  279. </if>
  280. <if test="serviceNumber != null and serviceNumber != ''">
  281. serviceNumber = #{serviceNumber},
  282. </if>
  283. <if test="maxBuyNumber != null and maxBuyNumber != ''">
  284. maxBuyNumber = #{maxBuyNumber},
  285. </if>
  286. <if test="minBuyNumber != null and minBuyNumber != ''">
  287. minBuyNumber = #{minBuyNumber},
  288. </if>
  289. <if test="packageCount != null and packageCount != ''">
  290. packageCount = #{packageCount},
  291. </if>
  292. <if test="byFlag != null and byFlag != ''">
  293. byFlag = #{byFlag},
  294. </if>
  295. <if test="step != null and step != ''">
  296. step = #{step},
  297. </if>
  298. <if test="freePostFlag != null and freePostFlag != ''">
  299. freePostFlag = #{freePostFlag},
  300. </if>
  301. <if test="precisehKey != null and precisehKey != ''">
  302. precisehKey = #{precisehKey},
  303. </if>
  304. <if test="docBoost != null and docBoost != ''">
  305. docBoost = #{docBoost},
  306. </if>
  307. productID = #{productID}
  308. WHERE productID = #{productID}
  309. </update>
  310. <delete id="delete">
  311. DELETE FROM cmme_product
  312. WHERE productID = #{productID}
  313. </delete>
  314. <select id="getProductImage" parameterType="com.cmme.modules.product.entity.CmmeProductImage" resultType="com.cmme.modules.product.entity.CmmeProductImage">
  315. SELECT *
  316. FROM cmme_productimage cp
  317. <where>
  318. <if test="shopID != null and shopID != ''">
  319. AND cp.shopID = #{shopID}
  320. </if>
  321. <if test="productID != null and productID != ''">
  322. AND cp.productID = #{productID}
  323. </if>
  324. </where>
  325. </select>
  326. <update id="updateProductDetail">
  327. UPDATE cmme_productdetailinfo SET
  328. <if test="detailInfo != null and detailInfo != ''">
  329. detailInfo = #{detailInfo},
  330. </if>
  331. <if test="detailInfoTxt != null and detailInfoTxt != ''">
  332. detailInfoTxt = #{detailInfoTxt},
  333. </if>
  334. <if test="seoTitle != null and seoTitle != ''">
  335. seoTitle = #{seoTitle},
  336. </if>
  337. <if test="seoKeyword != null and seoKeyword != ''">
  338. seoKeyword = #{seoKeyword},
  339. </if>
  340. <if test="seoDes != null and seoDes != ''">
  341. seoDes = #{seoDes},
  342. </if>
  343. <if test="technicalParameter != null and technicalParameter != ''">
  344. technicalParameter = #{technicalParameter},
  345. </if>
  346. <if test="expertOpinion != null and expertOpinion != ''">
  347. expertOpinion = #{expertOpinion},
  348. </if>
  349. <if test="clinicalResult != null and clinicalResult != ''">
  350. clinicalResult = #{clinicalResult},
  351. </if>
  352. <if test="video != null and video != ''">
  353. video = #{video},
  354. </if>
  355. productID = #{productID}
  356. WHERE productID = #{productID}
  357. </update>
  358. <update id="updataProductImage">
  359. UPDATE cmme_productimage SET
  360. <if test="shopID != null and shopID != ''">
  361. shopID = #{shopID},
  362. </if>
  363. <if test="addTime != null and addTime != ''">
  364. addTime = #{addTime},
  365. </if>
  366. <if test="image != null and image != ''">
  367. image = #{image},
  368. </if>
  369. <if test="mainFlag != null and mainFlag != ''">
  370. mainFlag = #{mainFlag},
  371. </if>
  372. <if test="sortIndex != null and sortIndex != ''">
  373. sortIndex = #{sortIndex},
  374. </if>
  375. productImageID = #{productImageID}
  376. WHERE productImageID = #{productImageID}
  377. </update>
  378. <insert id="saveProductImage" parameterType="com.cmme.modules.product.entity.CmmeProductImage" keyProperty="productDetailInfoID" useGeneratedKeys="true">
  379. INSERT INTO cmme_productimage(
  380. productID,
  381. shopID,
  382. addTime,
  383. image,
  384. mainFlag,
  385. sortIndex
  386. ) VALUES (
  387. #{productID},
  388. #{shopID},
  389. #{addTime},
  390. #{image},
  391. #{mainFlag},
  392. #{sortIndex}
  393. )
  394. </insert>
  395. <!--由于商品商家编码必须不唯一则重复编辑的时候查看不等于自己ID的shopCode是否重复-->
  396. <select id="getByShopCode" resultType="CmmeProduct">
  397. SELECT
  398. *
  399. FROM cmme_product a
  400. WHERE
  401. a.shopCode = #{shopCode}
  402. <if test="productID != null and productID != ''">
  403. AND a.productID != #{productID}
  404. </if>
  405. </select>
  406. </mapper>