123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.caimei365.manager.dao.KeyWordDao">
- <insert id="insertLabel">
- insert into cm_user_search_frequency(fromSearch, keyword, frequency, dynamicStatus, trueStatus, addTime)
- values (1, #{keyword}, 0, 0, 1, now())
- </insert>
- <insert id="insertLabelByExcel">
- insert into cm_user_search_frequency(fromSearch, keyword, frequency, trueStatus, dynamicStatus, addTime)
- values (3, #{keyword}, 0, 1, 0, now())
- </insert>
- <update id="updateLabelStatus">
- update cm_user_search_frequency
- set trueStatus = 1,
- fromSearch = 2,
- addTime = now()
- where id = #{id}
- </update>
- <update id="updateRecommendFlag">
- update cm_user_search_frequency
- set recommendFlag = 1
- where id = #{id}
- </update>
- <update id="updateDelFlag">
- update cm_user_search_frequency
- set delStatus = 0
- where id = #{id}
- </update>
- <update id="updateCmUserSearchFrequency" parameterType="com.caimei365.manager.entity.caimei.KeyWord">
- update cm_user_search_frequency
- <trim prefix="SET" suffixOverrides=",">
- <if test="fromSearch != null">fromSearch = #{fromSearch},</if>
- <if test="keyword != null and keyword != ''">keyword = #{keyword},</if>
- <if test="frequency != null">frequency = #{frequency},</if>
- <!-- <if test="trueStatus != null">trueStatus = #{trueStatus},</if>-->
- <!-- <if test="delStatus != null">delStatus = #{delStatus},</if>-->
- <!-- <if test="linkageFrequency != null">linkageFrequency = #{linkageFrequency},</if>-->
- <if test="linkageStatus != null">linkageStatus = #{linkageStatus},</if>
- <if test="searchTime != null">searchTime = #{searchTime},</if>
- <!-- <if test="recommendStatus != null and recommendStatus != ''">recommendStatus = #{recommendStatus},</if>-->
- <if test="recommendTime != null">recommendTime = #{recommendTime},</if>
- <!-- <if test="recommendFlag != null and recommendFlag != ''">recommendFlag = #{recommendFlag},</if>-->
- <if test="addTime != null">addTime = #{addTime},</if>
- </trim>
- where id = #{id}
- </update>
- <select id="findList" resultType="com.caimei365.manager.entity.caimei.KeyWord">
- SELECT cusf.id AS id, cusf.frequency, cusf.keyword as keyword, cusf.addTime, cusf.linkageStatus,
- cusf.searchTime as searchTime,cusf.trueStatus as labelStatus,cusf.fromSearch as fromSearch,
- cusf.dynamicStatus, s.linkMan as name,
- IFNULL(SUM(c.pv), 0) as pv
- FROM cm_user_search_frequency cusf
- left join serviceprovider s on cusf.serviceProviderId = s.serviceProviderID
- LEFT JOIN cm_praise_statistics c ON cusf.id = c.authorId
- WHERE cusf.delStatus = 1
- <if test="beginTime != null and beginTime !=''">
- AND c.createTime >= #{beginTime}
- </if>
- <if test="endTime != null and endTime !=''">
- AND c.createTime <![CDATA[ <= ]]> #{endTime}
- </if>
- <!-- <if test="beginTime !=null and beginTime !=''">-->
- <!-- AND (cusf.searchTime BETWEEN #{beginTime} AND #{endTime} or cusf.searchTime IS NULL)-->
- <!-- </if>-->
- <if test="keyword !=null and keyword !=''">
- AND cusf.keyword LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="labelStatus !=null">
- AND cusf.trueStatus = #{labelStatus}
- </if>
- <if test="fromSearch != null">
- AND cusf.fromSearch = #{fromSearch}
- </if>
- GROUP BY cusf.id
- ORDER BY cusf.frequency DESC, cusf.searchTime DESC
- </select>
- <select id="findRecommendList" resultType="com.caimei365.manager.entity.caimei.KeyWord">
- SELECT keyWord, recommendTime, id,trueStatus as labelStatus
- FROM cm_user_search_frequency
- where trueStatus = 0
- and delStatus = 1
- and recommendFlag = 0
- and recommendStatus = 1
- <if test="beginTime !=null and beginTime !=''">
- AND recommendTime BETWEEN #{beginTime} AND #{endTime}
- </if>
- <if test="keyword !=null and keyword !=''">
- AND keyword LIKE CONCAT('%',#{keyword},'%')
- </if>
- </select>
- <select id="findLinkageStatus" resultType="java.util.HashMap">
- SELECT
- (SELECT id from info a WHERE
- a.enabledStatus = 1
- and a.onlineStatus = 2
- and a.delFlag = 0
- and a.labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
- as info,
- (SELECT p.productID from product p
- left join cm_organize_product_info copi on copi.productId = p.productId
- where copi.validFlag = 2
- and copi.organizeId=0
- and p.labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
- as product,
- (SELECT id from cm_baike_product a
- WHERE a.delFlag = 0
- and a.status = 1
- and a.auditStatus = 2
- and a.onlineStatus = 2
- and a.labelIds LIKE CONCAT('%',cusf.id,'%')LIMIT 0,1)
- as cm_baike_product,
- (SELECT id from cm_product_archive_content
- WHERE labelIds LIKE CONCAT('%',cusf.id,'%') LIMIT 0,1)
- as cm_product_archive
- from cm_user_search_frequency as cusf
- WHERE id = #{id}
- </select>
- <select id="findKeywordExist" resultType="java.lang.Integer">
- select id
- from cm_user_search_frequency
- where keyword = #{keyword}
- and delstatus = 1
- limit 1
- </select>
- <select id="getKeywordByName" resultType="java.lang.Integer">
- select id
- from cm_keyword_info
- where keyword = #{keyword}
- and delFlag = 1
- limit 1
- </select>
- <select id="getServiceList" resultType="com.caimei365.manager.entity.caimei.cmUser.ServiceProviderModel">
- SELECT
- ser.serviceProviderID AS serviceProviderId,
- ser.linkMan,
- ser.userID AS userId
- FROM serviceprovider ser
- WHERE ser.organizeId = 0 AND ser.validFlag = 1 AND ser.status = 90 GROUP BY ser.serviceProviderID
- order by ser.addTime asc
- </select>
- <select id="getStateKeyWordList" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
- SELECT cki.id AS id,
- cki.keyword AS keyword,
- cki.fromSearch AS fromSearch,
- cki.serviceProviderId,
- cki.dynamicStatus,
- cki.parentLabel,
- cki.addTime,
- s.linkMan AS NAME
- FROM cm_keyword_info cki
- LEFT JOIN serviceprovider s ON cki.serviceProviderId = s.serviceProviderID
- <where>
- cki.delFlag = 1
- <if test="dynamicStatus != null">
- AND cki.dynamicStatus = #{dynamicStatus}
- </if>
- <if test="parentLabel != null">
- AND cki.parentLabel = #{parentLabel}
- </if>
- <if test="beginTime !=null and beginTime !=''">
- AND (cki.addTime BETWEEN #{beginTime} AND #{endTime} or cki.addTime IS NULL)
- </if>
- <if test="keyword !=null and keyword !=''">
- AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="fromSearch != null">
- AND cki.fromSearch = #{fromSearch}
- </if>
- <if test="serviceProviderId != null">
- AND cki.serviceProviderId = #{serviceProviderId}
- </if>
- </where>
- ORDER BY cki.addTime DESC
- </select>
- <select id="getkeywordById" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
- SELECT
- id AS id,
- keyword AS keyword,
- ifnull(parentLabel, 0) as parentLabel,
- fromSearch AS fromSearch,
- serviceProviderId,
- dynamicStatus,
- addTime
- FROM cm_keyword_info
- where delFlag = 1 and id = #{id}
- </select>
- <select id="getkeywordSubtag" resultType="com.caimei365.manager.entity.caimei.CmKeywordSubtag">
- SELECT
- cks.id AS id,
- cki.keyword AS keyword,
- cks.addTime
- FROM cm_keyword_subtag cks
- left join cm_keyword_info cki on cks.subtagId = cki.id
- where cki.delFlag = 1 and cks.delFlag = 0 and cks.keywordId = #{id}
- </select>
- <select id="getKeyword" resultType="com.caimei365.manager.entity.caimei.CmKeywordInfo">
- SELECT
- id AS id,
- keyword AS keyword,
- parentLabel,
- fromSearch AS fromSearch,
- serviceProviderId,
- dynamicStatus,
- addTime
- FROM cm_keyword_info
- <where>
- delFlag = 1 and parentLabel = 0
- <if test="keyword != null and keyword != ''">
- and keyword like concat ('%', #{keyword} , '%')
- </if>
- </where>
- order by addTime desc
- </select>
- <insert id="insertKeywordInfo" keyProperty="id" keyColumn="id" useGeneratedKeys="true">
- insert into cm_keyword_info(fromSearch, keyword, dynamicStatus, parentLabel, addTime, linkageStatus, delFlag)
- values (1, #{keyword}, #{dynamicStatus}, #{parentLabel}, now(), 0, 1)
- </insert>
- <update id="updateKeyword">
- update cm_keyword_info
- set keyword = #{keyword},
- parentLabel = #{parentLabel}
- where id = #{id}
- </update>
- <insert id="insertKeywordSubtag" keyProperty="subtagId" keyColumn="id" useGeneratedKeys="true">
- insert into cm_keyword_subtag(keywordId, subtagId, addTime, delFlag)
- values (#{keywordId}, #{subtagId}, now(), 0)
- </insert>
- <update id="updateKeywordSubtag">
- update cm_keyword_subtag
- set delFlag = 1
- where keywordId = #{keywordId}
- <if test="ids.size()>0">
- and subtagId not in
- <foreach collection="ids" item="id" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- </update>
- <update id="updateKeywordInfo">
- update cm_keyword_info
- set delFlag = 0
- where id = #{id}
- </update>
- <select id="getPriorKeywordList" resultType="com.caimei365.manager.entity.caimei.CmPriorKeyword">
- select
- cpk.id, cpk.searchId AS searchId ,cki.fromSearch as fromSearch, cki.keyword as keyword, cki.dynamicStatus,
- cki.serviceProviderId, cpk.addTime, s.linkMan as name
- from cm_prior_keyword cpk
- left join cm_keyword_info cki on cpk.searchId = cki.id
- left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
- WHERE cpk.delFlag = 0 AND cki.delFlag = 1
- <if test="keyword !=null and keyword !=''">
- AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="fromSearch != null">
- AND cki.fromSearch = #{fromSearch}
- </if>
- <if test="dynamicStatus != null">
- AND cki.dynamicStatus = #{dynamicStatus}
- </if>
- order by cpk.addTime desc
- </select>
- <select id="getPickKeyword" resultType="com.caimei365.manager.entity.caimei.KeyWord">
- SELECT
- cki.id AS id,
- cki.keyword as keyword,
- cki.addTime,
- cki.fromSearch as fromSearch,
- cki.serviceProviderId,
- cki.dynamicStatus,
- s.linkMan as name
- FROM cm_keyword_info cki
- left join serviceprovider s on cki.serviceProviderId = s.serviceProviderID
- WHERE cki.delFlag = 1
- <if test="keyword !=null and keyword !=''">
- AND cki.keyword LIKE CONCAT('%',#{keyword},'%')
- </if>
- <if test="fromSearch != null">
- AND cki.fromSearch = #{fromSearch}
- </if>
- <if test="dynamicStatus != null">
- AND cki.dynamicStatus = #{dynamicStatus}
- </if>
- ORDER BY cki.addTime DESC
- </select>
- <select id="getPriorCount" resultType="java.lang.Integer">
- select count(id) from cm_prior_keyword where delFlag = 0
- </select>
- <select id="getPrior" resultType="java.lang.Integer">
- select id from cm_prior_keyword where delFlag = 0 and searchId = #{searchId}
- </select>
- <insert id="insertPriorKeyword">
- insert into cm_prior_keyword (searchId, addTime, delFlag)
- values (#{searchId}, now(), 0)
- </insert>
- <update id="delPriorKeyword">
- update cm_prior_keyword
- set delFlag = 1
- where id = #{id}
- </update>
- <update id="delPriorKeywordById">
- update cm_prior_keyword
- set delFlag = 1
- where searchId = #{id}
- </update>
- </mapper>
|