KeyWordDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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.caimei365.manager.dao.KeyWordDao">
  4. <insert id="insertLabel">
  5. insert into cm_user_search_frequency(fromSearch, keyword, frequency, dynamicStatus, trueStatus, addTime)
  6. values (1, #{keyword}, 0, 0, 1, now())
  7. </insert>
  8. <insert id="insertLabelByExcel">
  9. insert into cm_user_search_frequency(fromSearch, keyword, frequency, trueStatus, dynamicStatus, addTime)
  10. values (3, #{keyword}, 0, 1, 0, now())
  11. </insert>
  12. <update id="updateLabelStatus">
  13. update cm_user_search_frequency
  14. set trueStatus = 1,
  15. fromSearch = 2,
  16. addTime = now()
  17. where id = #{id}
  18. </update>
  19. <update id="updateRecommendFlag">
  20. update cm_user_search_frequency
  21. set recommendFlag = 1
  22. where id = #{id}
  23. </update>
  24. <update id="updateDelFlag">
  25. update cm_user_search_frequency
  26. set delStatus = 0
  27. where id = #{id}
  28. </update>
  29. <update id="updateCmUserSearchFrequency" parameterType="com.caimei365.manager.entity.caimei.KeyWord">
  30. update cm_user_search_frequency
  31. <trim prefix="SET" suffixOverrides=",">
  32. <if test="fromSearch != null">fromSearch = #{fromSearch},</if>
  33. <if test="keyword != null and keyword != ''">keyword = #{keyword},</if>
  34. <if test="frequency != null">frequency = #{frequency},</if>
  35. <!-- <if test="trueStatus != null">trueStatus = #{trueStatus},</if>-->
  36. <!-- <if test="delStatus != null">delStatus = #{delStatus},</if>-->
  37. <!-- <if test="linkageFrequency != null">linkageFrequency = #{linkageFrequency},</if>-->
  38. <if test="linkageStatus != null">linkageStatus = #{linkageStatus},</if>
  39. <if test="searchTime != null">searchTime = #{searchTime},</if>
  40. <!-- <if test="recommendStatus != null and recommendStatus != ''">recommendStatus = #{recommendStatus},</if>-->
  41. <if test="recommendTime != null">recommendTime = #{recommendTime},</if>
  42. <!-- <if test="recommendFlag != null and recommendFlag != ''">recommendFlag = #{recommendFlag},</if>-->
  43. <if test="addTime != null">addTime = #{addTime},</if>
  44. </trim>
  45. where id = #{id}
  46. </update>
  47. <select id="findList" resultType="com.caimei365.manager.entity.caimei.KeyWord">
  48. SELECT cusf.id AS id, cusf.frequency, cusf.keyword as keyword, cusf.addTime, cusf.linkageStatus,
  49. cusf.searchTime as searchTime,cusf.trueStatus as labelStatus,cusf.fromSearch as fromSearch,
  50. cusf.dynamicStatus, s.linkMan as name,
  51. IFNULL(SUM(c.pv), 0) as pv
  52. FROM cm_user_search_frequency cusf
  53. left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
  54. LEFT JOIN cm_praise_statistics c ON cusf.id = c.authorId
  55. WHERE cusf.delStatus = 1
  56. <if test="beginTime != null and beginTime !=''">
  57. AND c.createTime >= #{beginTime}
  58. </if>
  59. <if test="endTime != null and endTime !=''">
  60. AND c.createTime <![CDATA[ <= ]]> #{endTime}
  61. </if>
  62. <!-- <if test="beginTime !=null and beginTime !=''">-->
  63. <!-- AND (cusf.searchTime BETWEEN #{beginTime} AND #{endTime} or cusf.searchTime IS NULL)-->
  64. <!-- </if>-->
  65. <if test="keyword !=null and keyword !=''">
  66. AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
  67. </if>
  68. <if test="labelStatus !=null">
  69. AND cusf.trueStatus = #{labelStatus}
  70. </if>
  71. <if test="fromSearch != null">
  72. AND cusf.fromSearch = #{fromSearch}
  73. </if>
  74. GROUP BY cusf.id
  75. ORDER BY cusf.frequency DESC, cusf.searchTime DESC
  76. </select>
  77. <select id="findRecommendList" resultType="com.caimei365.manager.entity.caimei.KeyWord">
  78. SELECT keyWord, recommendTime, id,trueStatus as labelStatus
  79. FROM cm_user_search_frequency
  80. where trueStatus = 0
  81. and delStatus = 1
  82. and recommendFlag = 0
  83. and recommendStatus = 1
  84. <if test="beginTime !=null and beginTime !=''">
  85. AND recommendTime BETWEEN #{beginTime} AND #{endTime}
  86. </if>
  87. <if test="keyword !=null and keyword !=''">
  88. AND keyword LIKE CONCAT('%',#{keyword},'%')
  89. </if>
  90. </select>
  91. <select id="findLinkageStatus" resultType="java.util.HashMap">
  92. SELECT
  93. (SELECT id from info a WHERE
  94. a.enabledStatus = 1
  95. and a.onlineStatus = 2
  96. and a.delFlag = 0
  97. and a.labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
  98. as info,
  99. (SELECT p.productID from product p
  100. left join cm_organize_product_info copi on copi.productId = p.productId
  101. where copi.validFlag = 2
  102. and copi.organizeId=0
  103. and p.labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
  104. as product,
  105. (SELECT id from cm_baike_product a
  106. WHERE a.delFlag = 0
  107. and a.status = 1
  108. and a.auditStatus = 2
  109. and a.onlineStatus = 2
  110. and a.labelIds LIKE CONCAT('%',cusf.id,'%')LIMIT 0,1)
  111. as cm_baike_product,
  112. (SELECT id from cm_product_archive_content
  113. WHERE labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
  114. as cm_product_archive
  115. from cm_user_search_frequency as cusf
  116. WHERE id = #{id}
  117. </select>
  118. <select id="findKeywordExist" resultType="java.lang.Integer">
  119. select id
  120. from cm_user_search_frequency
  121. where keyword = #{keyword}
  122. and delstatus = 1
  123. limit 1
  124. </select>
  125. <select id="getKeywordByName" resultType="java.lang.Integer">
  126. select id
  127. from cm_keyword_info
  128. where keyword = #{keyword}
  129. and delFlag = 1
  130. limit 1
  131. </select>
  132. <select id="getServiceList" resultType="com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel">
  133. SELECT
  134. ser.serviceProviderID AS serviceProviderId,
  135. ser.linkMan,
  136. ser.userID AS userId
  137. FROM serviceprovider ser
  138. WHERE ser.organizeId = 0 AND ser.validFlag = 1 AND ser.status = 90 GROUP BY ser.serviceProviderID
  139. order by ser.addTime asc
  140. </select>
  141. <select id="getStateKeyWordList" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
  142. SELECT cki.id AS id,
  143. cki.keyword AS keyword,
  144. cki.fromSearch AS fromSearch,
  145. cki.serviceProviderId,
  146. cki.dynamicStatus,
  147. cki.parentLabel,
  148. cki.addTime,
  149. s.linkMan AS NAME
  150. FROM cm_keyword_info cki
  151. LEFT JOIN serviceprovider s ON cki.serviceProviderId = s.serviceProviderID
  152. <where>
  153. cki.delFlag = 1
  154. <if test="dynamicStatus != null">
  155. AND cki.dynamicStatus = #{dynamicStatus}
  156. </if>
  157. <if test="parentLabel != null">
  158. AND cki.parentLabel = #{parentLabel}
  159. </if>
  160. <if test="beginTime !=null and beginTime !=''">
  161. AND (cki.addTime BETWEEN #{beginTime} AND #{endTime} or cki.addTime IS NULL)
  162. </if>
  163. <if test="keyword !=null and keyword !=''">
  164. AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
  165. </if>
  166. <if test="fromSearch != null">
  167. AND cki.fromSearch = #{fromSearch}
  168. </if>
  169. <if test="serviceProviderId != null">
  170. AND cki.serviceProviderId = #{serviceProviderId}
  171. </if>
  172. </where>
  173. ORDER BY cki.addTime DESC
  174. </select>
  175. <select id="getkeywordById" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
  176. SELECT
  177. id AS id,
  178. keyword AS keyword,
  179. ifnull(parentLabel, 0) as parentLabel,
  180. fromSearch AS fromSearch,
  181. serviceProviderId,
  182. dynamicStatus,
  183. addTime
  184. FROM cm_keyword_info
  185. where delFlag = 1 and id = #{id}
  186. </select>
  187. <select id="getkeywordSubtag" resultType="com.caimei365.manager.entity.caimei.CmKeywordSubtag">
  188. SELECT
  189. cks.id AS id,
  190. cki.keyword AS keyword,
  191. cks.addTime
  192. FROM cm_keyword_subtag cks
  193. left join cm_keyword_info cki on cks.subtagId = cki.id
  194. where cki.delFlag = 1 and cks.delFlag = 0 and cks.keywordId = #{id}
  195. </select>
  196. <select id="getKeyword" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
  197. SELECT
  198. id AS id,
  199. keyword AS keyword,
  200. parentLabel,
  201. fromSearch AS fromSearch,
  202. serviceProviderId,
  203. dynamicStatus,
  204. addTime
  205. FROM cm_keyword_info
  206. <where>
  207. delFlag = 1 and parentLabel = 0
  208. <if test="keyword != null and keyword != ''">
  209. and keyword like concat ('%', #{keyword} , '%')
  210. </if>
  211. </where>
  212. order by addTime desc
  213. </select>
  214. <insert id="insertKeywordInfo" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
  215. insert into cm_keyword_info(fromSearch, keyword, dynamicStatus, parentLabel, addTime, linkageStatus, delFlag)
  216. values (1, #{keyword}, #{dynamicStatus}, #{parentLabel}, now(), 0, 1)
  217. </insert>
  218. <update id="updateKeyword">
  219. update cm_keyword_info
  220. set keyword = #{keyword},
  221. parentLabel = #{parentLabel}
  222. where id = #{id}
  223. </update>
  224. <insert id="insertKeywordSubtag" keyProperty="subtagId" keyColumn="id" useGeneratedKeys="true">
  225. insert into cm_keyword_subtag(keywordId, subtagId, addTime, delFlag)
  226. values (#{keywordId}, #{subtagId}, now(), 0)
  227. </insert>
  228. <update id="updateKeywordSubtag">
  229. update cm_keyword_subtag
  230. set delFlag = 1
  231. where keywordId = #{keywordId}
  232. <if test="ids.size()>0">
  233. and subtagId not in
  234. <foreach collection="ids" item="id" open="(" separator="," close=")">
  235. #{id}
  236. </foreach>
  237. </if>
  238. </update>
  239. <update id="updateKeywordInfo">
  240. update cm_keyword_info
  241. set delFlag = 0
  242. where id = #{id}
  243. </update>
  244. <select id="getPriorKeywordList" resultType="com.caimei365.manager.entity.caimei.CmPriorKeyword">
  245. select
  246. cpk.id, cpk.searchId AS searchId ,cki.fromSearch as fromSearch, cki.keyword as keyword, cki.dynamicStatus,
  247. cki.serviceProviderId, cpk.addTime, s.linkMan as name
  248. from cm_prior_keyword cpk
  249. left join cm_keyword_info cki on cpk.searchId = cki.id
  250. left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
  251. WHERE cpk.delFlag = 0 AND cki.delFlag = 1
  252. <if test="keyword !=null and keyword !=''">
  253. AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
  254. </if>
  255. <if test="fromSearch != null">
  256. AND cki.fromSearch = #{fromSearch}
  257. </if>
  258. <if test="dynamicStatus != null">
  259. AND cki.dynamicStatus = #{dynamicStatus}
  260. </if>
  261. order by cpk.addTime desc
  262. </select>
  263. <select id="getPickKeyword" resultType="com.caimei365.manager.entity.caimei.KeyWord">
  264. SELECT
  265. cki.id AS id,
  266. cki.keyword as keyword,
  267. cki.addTime,
  268. cki.fromSearch as fromSearch,
  269. cki.serviceProviderId,
  270. cki.dynamicStatus,
  271. s.linkMan as name
  272. FROM cm_keyword_info cki
  273. left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
  274. WHERE cki.delFlag = 1
  275. <if test="keyword !=null and keyword !=''">
  276. AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
  277. </if>
  278. <if test="fromSearch != null">
  279. AND cki.fromSearch = #{fromSearch}
  280. </if>
  281. <if test="dynamicStatus != null">
  282. AND cki.dynamicStatus = #{dynamicStatus}
  283. </if>
  284. ORDER BY cki.addTime DESC
  285. </select>
  286. <select id="getPriorCount" resultType="java.lang.Integer">
  287. select count(id) from cm_prior_keyword where delFlag = 0
  288. </select>
  289. <select id="getPrior" resultType="java.lang.Integer">
  290. select id from cm_prior_keyword where delFlag = 0 and searchId = #{searchId}
  291. </select>
  292. <insert id="insertPriorKeyword">
  293. insert into cm_prior_keyword (searchId, addTime, delFlag)
  294. values (#{searchId}, now(), 0)
  295. </insert>
  296. <update id="delPriorKeyword">
  297. update cm_prior_keyword
  298. set delFlag = 1
  299. where id = #{id}
  300. </update>
  301. <update id="delPriorKeywordById">
  302. update cm_prior_keyword
  303. set delFlag = 1
  304. where searchId = #{id}
  305. </update>
  306. </mapper>