CmBaikeProductMapper.xml 16 KB

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