CmProductArchiveContentMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.caimei365.commodity.mapper.CmProductArchiveContentMapper">
  6. <select id="getByCmProductArchiveContent" parameterType="CmProductArchiveVO" resultType="CmProductArchiveVO">
  7. select
  8. cm_product_archive_content.id,
  9. cm_product_archive_content.productArchiveId,
  10. cm_product_archive_content.title,
  11. cm_product_archive_content.type,
  12. cm_product_archive_content.content,
  13. cm_product_archive_content.stageStatus,
  14. cm_product_archive_content.allStatus,
  15. cm_product_archive_content.labelIds,
  16. (SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords,
  17. cm_product_archive_content.addTime,
  18. cm_product_archive_content.spId,
  19. cpa.productId,
  20. cpa.productName,
  21. cpa.shopName,
  22. cpa.productImage as image,
  23. cpa.productType,
  24. cpa.productClassify
  25. ,IFNULL((select sum(c.pv) from cm_praise_statistics c where c.delFlag = 0 and c.type = 1 and cm_product_archive_content.id = c.authorId ), 0) as pv
  26. from cm_product_archive_content AS cm_product_archive_content
  27. left join cm_product_archive cpa on cpa.id = cm_product_archive_content.productArchiveId
  28. <where>
  29. <if test="id != null and id != ''">and cm_product_archive_content.id = #{id}</if>
  30. <if test="productArchiveId != null ">and cm_product_archive_content.productArchiveId = #{productArchiveId}
  31. </if>
  32. <if test="title != null and title != ''">and cm_product_archive_content.title like concat('%', #{title}, '%')</if>
  33. <if test="type != null and type != ''">and cm_product_archive_content.type = #{type}</if>
  34. <if test="content != null and content != ''">and cm_product_archive_content.content = #{content}</if>
  35. <if test="stageStatus != null ">and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  36. <if test="allStatus != null ">and cm_product_archive_content.allStatus = #{allStatus}</if>
  37. <if test="labelIds != null and labelIds != ''">and cm_product_archive_content.labelIds like concat('%', #{labelIds}, '%')</if>
  38. <if test="spId != null ">and cm_product_archive_content.spId = #{spId}</if>
  39. <if test="productId != null "> and cpa.productId = #{productId}</if>
  40. <if test="productName != null and productName != ''"> and cpa.productName like concat('%', #{productName}, '%')</if>
  41. <if test="shopName != null and shopName != ''"> and cpa.shopName like concat('%', #{shopName}, '%')</if>
  42. <if test="productType != null and productType != ''"> and cpa.productType = #{productType}</if>
  43. <if test="productClassify != null "> and cpa.productClassify = #{productClassify}</if>
  44. </where>
  45. limit 0,1
  46. </select>
  47. <select id="getCmProductArchiveContentList" parameterType="CmProductArchiveVO" resultType="CmProductArchiveVO">
  48. select
  49. cm_product_archive_content.id,
  50. cm_product_archive_content.productArchiveId,
  51. cm_product_archive_content.title,
  52. cm_product_archive_content.type,
  53. cm_product_archive_content.content,
  54. cm_product_archive_content.stageStatus,
  55. cm_product_archive_content.allStatus,
  56. cm_product_archive_content.labelIds,
  57. (SELECT GROUP_CONCAT(cusf.keyword) FROM cm_user_search_frequency cusf WHERE FIND_IN_SET(cusf.id ,cm_product_archive_content.labelIds)) as keywords,
  58. cm_product_archive_content.addTime,
  59. cm_product_archive_content.spId,
  60. cpa.productId,
  61. cpa.productName,
  62. cpa.shopName,
  63. cpa.productImage as image,
  64. cpa.productType,
  65. cpa.productClassify
  66. from cm_product_archive_content AS cm_product_archive_content
  67. left join cm_product_archive cpa on cpa.id = cm_product_archive_content.productArchiveId
  68. <where>
  69. <if test="id != null and id != ''">and cm_product_archive_content.id = #{id}</if>
  70. <if test="productArchiveId != null ">and cm_product_archive_content.productArchiveId = #{productArchiveId}
  71. </if>
  72. <if test="title != null and title != ''">and cm_product_archive_content.title like concat('%', #{title}, '%')</if>
  73. <if test="type != null and type != ''">and cm_product_archive_content.type = #{type}</if>
  74. <if test="content != null and content != ''">and cm_product_archive_content.content = #{content}</if>
  75. <if test="stageStatus != null ">and cm_product_archive_content.stageStatus = #{stageStatus}</if>
  76. <if test="allStatus != null ">and cm_product_archive_content.allStatus = #{allStatus}</if>
  77. <if test="labelIds != null and labelIds != ''">
  78. AND
  79. cm_product_archive_content.labelIds like concat('%', #{labelIds}, '%')
  80. </if>
  81. <if test="spId != null ">and cm_product_archive_content.spId = #{spId}</if>
  82. <if test="productId != null "> and cpa.productId = #{productId}</if>
  83. <if test="productName != null and productName != ''"> and cpa.productName like concat('%', #{productName}, '%')</if>
  84. <if test="shopName != null and shopName != ''"> and cpa.shopName like concat('%', #{shopName}, '%')</if>
  85. <if test="productType != null and productType != ''"> and cpa.productType = #{productType}</if>
  86. <if test="productClassify != null "> and cpa.productClassify = #{productClassify}</if>
  87. </where>
  88. order by cm_product_archive_content.addTime desc
  89. limit #{pageNum},5
  90. </select>
  91. <select id="getCmProductArchiveInfoList" resultType="CmProductArchiveVO">
  92. select
  93. info.id,
  94. info.guidanceImage as image,
  95. info.title,
  96. info.createDate as addTime,
  97. 6 as type
  98. from info AS info
  99. where info.delFlag=0
  100. and info.onlineStatus=2
  101. and info.enabledStatus=1
  102. <if test="labelIds != null and labelIds != ''">
  103. AND
  104. info.labelIds like concat('%', #{labelIds}, '%')
  105. </if>
  106. <if test="title != null and title != ''">and info.title like concat('%', #{title}, '%')</if>
  107. order by info.createDate desc
  108. limit #{pageNum},5
  109. </select>
  110. <select id="getCmProductArchiveBaikeList" resultType="CmProductArchiveVO">
  111. select
  112. cbp.id,
  113. cbp.image as image,
  114. cbp.name as title,
  115. cbp.addTime,
  116. 7 as type
  117. from cm_baike_product AS cbp
  118. where cbp.delFlag=0
  119. and cbp.onlineStatus=2
  120. and cbp.status=1
  121. <if test="labelIds != null and labelIds != ''">
  122. AND
  123. cbp.labelIds like concat('%', #{labelIds}, '%')
  124. </if>
  125. <if test="title != null and title != ''">and cbp.name like concat('%', #{title}, '%')</if>
  126. order by cbp.addTime desc
  127. limit #{pageNum},5
  128. </select>
  129. <select id="getProductArchiveFileList" resultType="String">
  130. select
  131. ifnull(waterOssUrl,ossUrl)
  132. from cm_product_archive_file
  133. <where>
  134. archiveContentId=#{id}
  135. </where>
  136. order by uploadTime desc
  137. </select>
  138. <insert id="addCmProductArchiveContent" parameterType="CmProductArchiveVO" useGeneratedKeys="true" keyProperty="id">
  139. insert into cm_product_archive_content
  140. <trim prefix="(" suffix=")" suffixOverrides=",">
  141. <if test="id != null and id != ''">id,</if>
  142. <if test="productArchiveId != null">productArchiveId,</if>
  143. <if test="title != null and title != ''">title,</if>
  144. <if test="type != null and type != ''">type,</if>
  145. <if test="content != null and content != ''">content,</if>
  146. <if test="stageStatus != null">stageStatus,</if>
  147. <if test="allStatus != null">allStatus,</if>
  148. <if test="labelIds != null and labelIds != ''">labelIds,</if>
  149. <if test="addTime != null">addTime,</if>
  150. <if test="createBy != null and createBy != ''">createBy,</if>
  151. <if test="spId != null">spId,</if>
  152. </trim>
  153. <trim prefix="values (" suffix=")" suffixOverrides=",">
  154. <if test="id != null and id != ''">#{id},</if>
  155. <if test="productArchiveId != null">#{productArchiveId},</if>
  156. <if test="title != null and title != ''">#{title},</if>
  157. <if test="type != null and type != ''">#{type},</if>
  158. <if test="content != null and content != ''">#{content},</if>
  159. <if test="stageStatus != null">#{stageStatus},</if>
  160. <if test="allStatus != null">#{allStatus},</if>
  161. <if test="labelIds != null and labelIds != ''">#{labelIds},</if>
  162. <if test="addTime != null">#{addTime},</if>
  163. <if test="createBy != null and createBy != ''">#{createBy},</if>
  164. <if test="spId != null">#{spId},</if>
  165. </trim>
  166. </insert>
  167. <update id="updateCmProductArchiveContent" parameterType="CmProductArchiveVO">
  168. update cm_product_archive_content
  169. <trim prefix="SET" suffixOverrides=",">
  170. <if test="productArchiveId != null">productArchiveId = #{productArchiveId},</if>
  171. <if test="title != null and title != ''">title = #{title},</if>
  172. <if test="type != null and type != ''">type = #{type},</if>
  173. <if test="content != null and content != ''">content = #{content},</if>
  174. <if test="stageStatus != null">stageStatus = #{stageStatus},</if>
  175. <if test="allStatus != null">allStatus = #{allStatus},</if>
  176. <if test="labelIds != null and labelIds != ''">labelIds = #{labelIds},</if>
  177. <if test="addTime != null">addTime = #{addTime},</if>
  178. <if test="createBy != null and createBy != ''">createBy = #{createBy},</if>
  179. <if test="spId != null">spId = #{spId},</if>
  180. </trim>
  181. where id = #{id}
  182. </update>
  183. <delete id="delCmProductArchiveContentById" parameterType="String">
  184. delete
  185. from cm_product_archive_content
  186. where id = #{id}
  187. </delete>
  188. <select id="findKeyWordList" resultType="KeyPo">
  189. SELECT cusf.id as k, cusf.keyword as v
  190. FROM cm_user_search_frequency cusf
  191. WHERE cusf.delStatus = 1
  192. <if test="v != null and v != ''">and cusf.keyword like concat('%', #{v}, '%')</if>
  193. and FIND_IN_SET(cusf.id ,(SELECT GROUP_CONCAT(cpac.labelIds) from cm_product_archive_content cpac))
  194. ORDER BY cusf.frequency DESC, cusf.searchTime DESC
  195. </select>
  196. <select id="findProductList" resultType="CmProductArchiveVO">
  197. SELECT a.shopName as shopName,
  198. ifnull(a.productName,p.name) as productName,
  199. a.`productID` as productId,
  200. ifnull(a.productImage,p.mainImage) as image
  201. FROM cm_product_archive a
  202. left join product p on p.productID=a.productId
  203. WHERE 1=1
  204. <if test="productId != null ">and a.productId = #{productId}</if>
  205. <if test="productName != null and productName != ''">
  206. and (a.productName like concat('%', #{productName}, '%') or p.name like concat('%', #{productName}, '%'))
  207. </if>
  208. <if test="shopName != null and shopName != ''">and a.shopName like concat('%', #{shopName}, '%')</if>
  209. and a.productId is not null
  210. group by a.productID
  211. order by a.productID desc
  212. </select>
  213. </mapper>