CmBaikeProductMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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.caimei.modules.baike.dao.CmBaikeProductDao">
  4. <sql id="cmBaikeProductColumns">
  5. a.id AS "id",
  6. a.commodityType AS "commodityType",
  7. a.publishSource,
  8. s.name as "shopName",
  9. a.shopId,
  10. a.productLink,
  11. a.name AS "name",
  12. a.alias AS "alias",
  13. a.discription AS "discription",
  14. a.seoKeyword,
  15. a.banner AS "banner",
  16. a.image AS "image",
  17. a.authLink,
  18. a.authQrCode,
  19. a.advantage AS "advantage",
  20. a.disadvantage AS "disadvantage",
  21. a.principle AS "principle",
  22. a.brand AS "brand",
  23. a.producePlace AS "producePlace",
  24. a.marketTime AS "marketTime",
  25. a.company AS "company",
  26. a.nmpaTime AS "nmpaTime",
  27. a.adaptiveMan AS "adaptiveMan",
  28. a.unAdaptiveMan AS "unAdaptiveMan",
  29. a.aroundOperation AS "aroundOperation",
  30. a.publishTime AS "publishTime",
  31. a.basePv AS "basePv",
  32. a.actualPv AS "actualPv",
  33. a.typeId AS "typeId",
  34. a.topPosition AS "topPosition",
  35. a.status AS "status",
  36. a.auditStatus,
  37. a.onlineStatus,
  38. a.failReason,
  39. a.addTime AS "addTime",
  40. a.recommendType,
  41. cbt.name as "typeName",
  42. a.labelIds as "labelIds"
  43. </sql>
  44. <sql id="cmBaikeProductJoins">
  45. left join cm_baike_type cbt on a.typeId = cbt.id
  46. left join shop s on a.shopId = s.shopID
  47. </sql>
  48. <select id="get" resultType="CmBaikeProduct">
  49. SELECT
  50. <include refid="cmBaikeProductColumns"/>
  51. FROM cm_baike_product a
  52. <include refid="cmBaikeProductJoins"/>
  53. WHERE a.id = #{id} and delFlag = 0
  54. </select>
  55. <select id="findList" resultType="CmBaikeProduct">
  56. SELECT
  57. <include refid="cmBaikeProductColumns"/>
  58. FROM cm_baike_product a
  59. <include refid="cmBaikeProductJoins"/>
  60. <where>
  61. delFlag = 0
  62. <if test="id != null and id != ''">
  63. AND a.id = #{id}
  64. </if>
  65. <if test="name != null and name != ''">
  66. AND a.name LIKE
  67. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  68. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  69. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  70. </if>
  71. <if test="typeId != null and typeId != ''">
  72. AND a.typeId = #{typeId}
  73. </if>
  74. <if test="topFlag != null">
  75. <choose>
  76. <when test='topFlag == 1'>
  77. and topPosition is not null and topPosition != ''
  78. </when>
  79. <when test='topFlag == 0'>
  80. and (topPosition is null or topPosition = '')
  81. </when>
  82. </choose>
  83. </if>
  84. <if test="topPosition != null">
  85. and topPosition = #{topPosition}
  86. </if>
  87. <if test="status != null">
  88. AND a.status = #{status}
  89. </if>
  90. <!-- <if test="commodityType != null">-->
  91. <!-- and a.commodityType = #{commodityType}-->
  92. <!-- </if>-->
  93. <if test="publishSource != null">
  94. and a.publishSource = #{publishSource}
  95. </if>
  96. <if test="auditStatus != null">
  97. and a.auditStatus = #{auditStatus}
  98. </if>
  99. <if test="onlineStatus != null">
  100. and a.onlineStatus = #{onlineStatus}
  101. </if>
  102. <if test="shopName != null and shopName != ''">
  103. AND s.name LIKE concat('%',#{shopName},'%')
  104. </if>
  105. <if test="productIds != null and productIds != ''">
  106. and a.id not in
  107. <foreach item="productId" collection="productIds.split(',')" open="(" separator="," close=")">
  108. #{productId}
  109. </foreach>
  110. </if>
  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. order by a.addTime desc
  118. </otherwise>
  119. </choose>
  120. </select>
  121. <select id="findAllList" resultType="CmBaikeProduct">
  122. SELECT
  123. <include refid="cmBaikeProductColumns"/>
  124. FROM cm_baike_product a
  125. <include refid="cmBaikeProductJoins"/>
  126. <where>
  127. </where>
  128. <choose>
  129. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  130. ORDER BY ${page.orderBy}
  131. </when>
  132. <otherwise>
  133. </otherwise>
  134. </choose>
  135. </select>
  136. <select id="findParamList" resultType="com.caimei.modules.baike.entity.CmBaikeProductParam">
  137. select productId, name, content
  138. from cm_baike_product_param
  139. where productId = #{id}
  140. </select>
  141. <select id="findImageList" resultType="java.lang.String">
  142. select image
  143. from cm_baike_product_image
  144. where productId = #{productId}
  145. and type = #{imageType}
  146. </select>
  147. <select id="findQuestionList" resultType="com.caimei.modules.baike.entity.CmBaikeProductQuestion">
  148. select productId, question, answer
  149. from cm_baike_product_question
  150. where productId = #{id}
  151. </select>
  152. <select id="findTopLength" resultType="java.lang.Integer">
  153. select count(*)
  154. from cm_baike_product
  155. where topPosition is not null
  156. and topPosition != ''
  157. </select>
  158. <select id="findShopList" resultType="com.caimei.modules.user.entity.NewCmShop">
  159. select s.shopID, u.name
  160. from shop s
  161. LEFT JOIN user u ON u.userID = s.userID
  162. where s.status = 90
  163. and u.userID is not null
  164. order by s.shopID desc;
  165. </select>
  166. <select id="checkFileName" resultType="java.lang.Integer">
  167. select id from cm_baike_product_file
  168. <where>
  169. fileName = #{fileName}
  170. <if test="productId != null || (fileIds != null and fileIds != '')">
  171. and(
  172. <if test="productId != null">
  173. productId = #{productId}
  174. </if>
  175. <if test="fileIds != null and fileIds != ''">
  176. or id in
  177. <foreach collection="fileIds.split(',')" item="fileId" index="index" open="(" separator=","
  178. close=")">
  179. #{fileId}
  180. </foreach>
  181. </if>
  182. )
  183. </if>
  184. </where>
  185. </select>
  186. <select id="getProductFileById" resultType="com.caimei.modules.baike.entity.CmBaikeProductFile">
  187. select productId, fileTitle, fileName, ossName
  188. from cm_baike_product_file
  189. where id = #{fileId}
  190. </select>
  191. <select id="findFileList" resultType="com.caimei.modules.baike.entity.CmBaikeProductFile">
  192. select id, productId, fileTitle, fileName, ossName
  193. from cm_baike_product_file
  194. where productId = #{id}
  195. </select>
  196. <insert id="insert" parameterType="CmBaikeProduct" keyProperty="id" useGeneratedKeys="true">
  197. INSERT INTO cm_baike_product(commodityType,
  198. name,
  199. shopId,
  200. productLink,
  201. alias,
  202. discription,
  203. seoKeyword,
  204. banner,
  205. image,
  206. authLink,
  207. authQrCode,
  208. advantage,
  209. disadvantage,
  210. principle,
  211. brand,
  212. producePlace,
  213. marketTime,
  214. company,
  215. nmpaTime,
  216. adaptiveMan,
  217. unAdaptiveMan,
  218. aroundOperation,
  219. publishTime,
  220. basePv,
  221. actualPv,
  222. typeId,
  223. emptyNum,
  224. status,
  225. addTime,
  226. labelIds,
  227. relatedLabels)
  228. VALUES (#{commodityType},
  229. #{name},
  230. #{shopId},
  231. #{productLink},
  232. #{alias},
  233. #{discription},
  234. #{seoKeyword},
  235. #{banner},
  236. #{image},
  237. #{authLink},
  238. #{authQrCode},
  239. #{advantage},
  240. #{disadvantage},
  241. #{principle},
  242. #{brand},
  243. #{producePlace},
  244. #{marketTime},
  245. #{company},
  246. #{nmpaTime},
  247. #{adaptiveMan},
  248. #{unAdaptiveMan},
  249. #{aroundOperation},
  250. #{publishTime},
  251. #{basePv},
  252. 0,
  253. #{typeId},
  254. #{emptyNum},
  255. #{status},
  256. NOW(),
  257. #{labelIds},
  258. #{labelStr})
  259. </insert>
  260. <insert id="insertProductImage">
  261. insert into cm_baike_product_image (productId, type, image)
  262. values (#{produtId}, #{imageType}, #{authImage})
  263. </insert>
  264. <insert id="insertProductParam">
  265. insert into cm_baike_product_param (productId, name, content)
  266. values (#{productId}, #{name}, #{content})
  267. </insert>
  268. <insert id="insertProductQuestion">
  269. insert into cm_baike_product_question (productId, question, answer)
  270. values (#{productId}, #{question}, #{answer})
  271. </insert>
  272. <insert id="insertProductFile" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
  273. insert into cm_baike_product_file(fileTitle, fileName, ossName, ossUrl)
  274. values (#{fileTitle}, #{fileName}, #{ossName}, #{ossUrl})
  275. </insert>
  276. <update id="update">
  277. UPDATE cm_baike_product SET
  278. name = #{name},
  279. shopId = #{shopId},
  280. productLink = #{productLink},
  281. alias = #{alias},
  282. discription = #{discription},
  283. seoKeyword = #{seoKeyword},
  284. banner = #{banner},
  285. image = #{image},
  286. authLink = #{authLink},
  287. authQrCode = #{authQrCode},
  288. advantage = #{advantage},
  289. disadvantage = #{disadvantage},
  290. principle = #{principle},
  291. brand = #{brand},
  292. producePlace = #{producePlace},
  293. marketTime = #{marketTime},
  294. company = #{company},
  295. nmpaTime = #{nmpaTime},
  296. adaptiveMan = #{adaptiveMan},
  297. unAdaptiveMan = #{unAdaptiveMan},
  298. aroundOperation = #{aroundOperation},
  299. publishTime = #{publishTime},
  300. basePv = #{basePv},
  301. typeId = #{typeId},
  302. emptyNum = #{emptyNum},
  303. <if test="auditFlag != null and auditFlag == 1">
  304. <if test="auditStatus != null">
  305. auditStatus = #{auditStatus},
  306. </if>
  307. <if test="onlineStatus != null">
  308. onlineStatus = #{onlineStatus},
  309. </if>
  310. <if test="failReason != null and failReason != ''">
  311. failReason = #{failReason},
  312. </if>
  313. </if>
  314. labelIds = #{labelIds},
  315. relatedLabels=#{labelStr},
  316. status = #{status}
  317. WHERE id = #{id}
  318. </update>
  319. <update id="updateStatus">
  320. update cm_baike_product
  321. set status = #{status}
  322. where id = #{productId}
  323. </update>
  324. <update id="updateTopPosition">
  325. update cm_baike_product
  326. set topPosition = #{topPosition}
  327. where id = #{id}
  328. </update>
  329. <update id="auditBaike">
  330. update cm_baike_product
  331. set auditStatus = #{auditStatus},
  332. failReason = #{failReason}
  333. <if test="publishTime != null">
  334. ,publishTime = #{publishTime}
  335. </if>
  336. where id = #{id}
  337. </update>
  338. <update id="offline">
  339. update cm_baike_product
  340. set onlineStatus = 3
  341. where id = #{id}
  342. </update>
  343. <update id="updateEmptyNum">
  344. update cm_baike_product
  345. set emptyNum = #{emptyNum}
  346. where id = #{id}
  347. </update>
  348. <update id="updateProductFile">
  349. update cm_baike_product_file
  350. set productId = #{productId}
  351. where id = #{fileId}
  352. </update>
  353. <update id="updateRecommendType">
  354. update cm_baike_product
  355. set recommendType = #{recommendType}
  356. where id = #{productId}
  357. </update>
  358. <delete id="delete">
  359. DELETE
  360. FROM cm_baike_product
  361. WHERE id = #{id}
  362. </delete>
  363. <delete id="deleteParamsByProductId">
  364. delete
  365. from cm_baike_product_param
  366. where productId = #{id}
  367. </delete>
  368. <delete id="deleteImagesByProductId">
  369. delete
  370. from cm_baike_product_image
  371. where productId = #{id}
  372. </delete>
  373. <delete id="deleteQuestionsByProductId">
  374. delete
  375. from cm_baike_product_question
  376. where productId = #{id}
  377. </delete>
  378. <delete id="delMaterialinfoBYProductId">
  379. delete
  380. from cm_baike_reference_info
  381. where productId = #{id}
  382. </delete>
  383. <delete id="delTextListByEntryId">
  384. delete
  385. from cm_baike_text_info
  386. where productId = #{id}
  387. </delete>
  388. <delete id="deleteProductFile">
  389. delete
  390. from cm_baike_product_file
  391. where id = #{fileId}
  392. </delete>
  393. <select id="getTextInfo" resultType="com.caimei.modules.baike.entity.CmBaikeTextInfo">
  394. select *
  395. from cm_baike_text_info
  396. where productId = #{productId}
  397. </select>
  398. <insert id="saveMaterialinfo">
  399. insert into cm_baike_reference_info(referenceType, website, articleName, websiteName, publishTime,
  400. acitationTime, author, workName, publicationPlace, press, publicationYear,
  401. acitationWeb, referenceDescription, imageDescription, imageUrl, productId,
  402. productType, ctrlId)
  403. values (#{referenceType}, #{website}, #{articleName}, #{websiteName}, #{publishTimeStr}, #{acitationTimeStr},
  404. #{author}, #{workName}, #{publicationPlace}, #{press}, #{publicationYearStr}, #{acitationWeb},
  405. #{referenceDescription}, #{imageDescription}, #{imageUrl}, #{productId}, #{productType}, #{ctrlId})
  406. </insert>
  407. <update id="upMaterialinfo">
  408. update cm_baike_reference_info
  409. set referenceType=#{referenceType},
  410. website=#{website},
  411. articleName=#{articleName},
  412. websiteName=#{websiteName},
  413. publishTime=#{publishTimeStr},
  414. acitationTime=#{acitationTimeStr},
  415. author=#{author},
  416. workName=#{workName},
  417. publicationPlace=#{publicationPlace},
  418. press=#{press},
  419. publicationYear=#{publicationYearStr},
  420. acitationWeb=#{acitationWeb},
  421. referenceDescription=#{referenceDescription},
  422. imageDescription=#{imageDescription},
  423. imageUrl=#{imageUrl}
  424. where id = #{id}
  425. </update>
  426. <insert id="insertText">
  427. insert into cm_baike_text_info(textType, productId, dictionaryContent, referenceId, parentId, dictionaryType)
  428. values (#{textType}, #{productId}, #{dictionaryContent}, #{referenceId}, #{parentId}, #{dictionaryType})
  429. </insert>
  430. <select id="getMaterialInfo" resultType="com.caimei.modules.baike.entity.CmBaikeReferenceInfo">
  431. select *
  432. from cm_baike_reference_info
  433. where productId = #{productId}
  434. </select>
  435. <delete id="delMaterialinfo">
  436. delete
  437. from cm_baike_reference_info
  438. where id = #{id}
  439. </delete>
  440. <select id="getMaterialinfo" resultType="com.caimei.modules.baike.entity.CmBaikeReferenceInfo">
  441. select *
  442. from cm_baike_reference_info
  443. where id = #{id}
  444. </select>
  445. </mapper>