KeyWordDao.xml 13 KB

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