MVC-CZBK.ItcastOA.BLL.KeyWordsRankService.cs

本文介绍了一个关键词排名服务的实现细节,包括将统计的明细表数据插入关键词排名表、删除汇总中的数据以及根据搜索词获取关键词信息的方法。通过SQL语句实现了数据的批量操作,如插入新的关键词排名记录和清空现有排名数据。

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CZBK.ItcastOA.BLL
{
   public partial class KeyWordsRankService:BaseService<Model.KeyWordsRank>,IBLL.IKeyWordsRankService
    {
       /// <summary>
       /// 将统计的明细表的数据插入。
       /// </summary>
       /// <returns></returns>
        public bool InsertKeyWordsRank()
        {
            string sql = "insert into KeyWordsRank(Id,KeyWords,SearchCount) select newid(),KeyWords,count(*)  from SearchDetails where DateDiff(day,SearchDetails.SearchDateTime,getdate())<=7 group by SearchDetails.KeyWords";
            return this.CurrentDBSession.ExecuteSql(sql)>0;
        }
       /// <summary>
       /// 删除汇总中的数据。
       /// </summary>
       /// <returns></returns>
        public bool DeleteAllKeyWordsRank()
        {
            string sql = "truncate table KeyWordsRank";
           return this.CurrentDBSession.ExecuteSql(sql)>0;
        }
        public List<string> GetSearchMsg(string term)
        {
           //KeyWords like term%
            string sql = "select KeyWords from KeyWordsRank where KeyWords like @term";
           return this.CurrentDBSession.ExecuteQuery<string>(sql, new SqlParameter("@term",term+"%" ));
        }
    }
}
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值