!71 评论增加过滤敏感词的功能

* Merge branch 'develop' into dahuihui/develop
* 增加过滤敏感词的功能。#I3W6CM
* 增加Issue 和 Pull Request 模板
* 修复自定义上传路径上传至站点根目录,而非wwwroot的问题 #I41TD1
* Merge branch 'develop' into dahuihui/develop
* 修复自定义上传路径的表单命名异常问题
* 使用新数据库
* 【数据库】修复mysql数据库decimal类型未带小数的问题。#I3WAUY
* 更新数据库及脚本
* 2021-07-20
* Merge branch 'develop' into dahuihui/develop
* 修复webapi不进入调试断点的问题。
* Merge branch 'develop' into dahuihui/develop
* 修复后台前后端分离table面板启用自定义域名问题。
* 修复后台前后端分离域名未增加到html问题。
* Merge branch 'develop' into dahuihui/develop
* 【后端】修复修改登录用户真实姓名长度问题。
* 修复后台管理配送方式维护错误问题
* 1、修复小程序注册问题,导致交互事情。不然盛派的组件有bug,在不注册微信公众号只注册微信小程序的时候,进行小程序消息操作,默认还是走的是微…
* 修复消息模板不推送的问题
* Merge branch 'develop' into dahuihui/develop
* Merge branch 'develop' into dahuihui/develop
* 修复过期失效文档
* 调整代码生成器,增加初始化事务
* 调整接口端提示界面
* 修复弹窗不居中问题
* 调整一些命名方式
* 修复uni-app前端,用户订单列表【确认收货】按钮失效问题
* 1、修复mysql数据库下,报表统计sql的语法错误。2、为方便前端在不部署接口及后端的情况下测试uni-app前端,默认增加了测试接口地址…
* Merge branch 'develop' into dahuihui/develop
* 调整命名
* 增加docker-compose部署
* Merge branch 'develop' into dahuihui/develop
* 修复因linux下存在数据与文件名称大小写不对应,导致找不到数据库表的问题,特重新发布一份表名与实体名称一一对应脚本。
* 新mysql表名存在大小写问题
pull/72/head
大灰灰 4 years ago
parent 4b7c9485ce
commit 56b9c45ef4

@ -283,6 +283,20 @@
}
/// <summary>
/// Tools工具常量
/// </summary>
public static class ToolsVars
{
/// <summary>
///
/// </summary>
public const string IllegalWordsCahceName = "IllegalWordsCahce";
}
/// <summary>
/// 权限变量配置
/// </summary>

@ -0,0 +1,39 @@
/***********************************************************************
* Project: CoreCms
* ProjectName:
* Web: https://www.corecms.net
* Author:
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description:
***********************************************************************/
using System;
using System.Threading.Tasks;
using CoreCms.Net.Model.Entities;
namespace CoreCms.Net.IServices
{
/// <summary>
/// 标签表 服务工厂接口
/// </summary>
public interface IToolsServices
{
/// <summary>
/// 查询是否存在违规内容并进行替换
/// </summary>
/// <returns></returns>
Task<String> IllegalWordsReplace(string oldString, char symbol = '*');
/// <summary>
/// 查询是否存在违规内容
/// </summary>
/// <returns></returns>
Task<bool> IllegalWordsContainsAny(string oldString);
}
}

@ -0,0 +1,101 @@
/***********************************************************************
* Project: CoreCms
* ProjectName:
* Web: https://www.corecms.net
* Author:
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description:
***********************************************************************/
using System;
using System.IO;
using System.Threading.Tasks;
using CoreCms.Net.Caching.Manual;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.FileProviders;
using ToolGood.Words;
namespace CoreCms.Net.Services
{
/// <summary>
/// 标签表 接口实现
/// </summary>
public class ToolsServices : IToolsServices
{
private IWebHostEnvironment _hostEnvironment;
public ToolsServices(IWebHostEnvironment hostEnvironment)
{
_hostEnvironment = hostEnvironment;
}
/// <summary>
/// 查询是否存在违规内容并进行替换
/// </summary>
/// <returns></returns>
public async Task<String> IllegalWordsReplace(string oldString, char symbol = '*')
{
var cache = ManualDataCache.Instance.Get<string>(ToolsVars.IllegalWordsCahceName);
if (string.IsNullOrEmpty(cache))
{
IFileProvider fileProvider = this._hostEnvironment.ContentRootFileProvider;
IFileInfo fileInfo = fileProvider.GetFileInfo("illegalWord/IllegalKeywords.txt");
string fileContent = null;
using (StreamReader readSteam = new StreamReader(fileInfo.CreateReadStream()))
{
fileContent = await readSteam.ReadToEndAsync();
}
cache = fileContent;
ManualDataCache.Instance.Set(ToolsVars.IllegalWordsCahceName, cache);
}
WordsMatch wordsSearch = new WordsMatch();
wordsSearch.SetKeywords(cache.Split("|"));
var t = wordsSearch.Replace(oldString, symbol);
return t;
}
/// <summary>
/// 查询是否存在违规内容
/// </summary>
/// <returns></returns>
public async Task<bool> IllegalWordsContainsAny(string oldString)
{
var cache = ManualDataCache.Instance.Get<string>(ToolsVars.IllegalWordsCahceName);
if (string.IsNullOrEmpty(cache))
{
IFileProvider fileProvider = this._hostEnvironment.ContentRootFileProvider;
IFileInfo fileInfo = fileProvider.GetFileInfo("illegalWord/IllegalKeywords.txt");
string fileContent = null;
using (StreamReader readSteam = new StreamReader(fileInfo.CreateReadStream()))
{
fileContent = await readSteam.ReadToEndAsync();
}
cache = fileContent;
ManualDataCache.Instance.Set(ToolsVars.IllegalWordsCahceName, cache);
}
WordsMatch wordsSearch = new WordsMatch();
wordsSearch.SetKeywords(cache.Split("|"));
var bl = wordsSearch.ContainsAny(oldString);
return bl;
}
}
}

@ -21,6 +21,7 @@
<PackageReference Include="Senparc.Weixin.MP" Version="16.12.400" />
<PackageReference Include="Senparc.Weixin.WxOpen" Version="3.11.400" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
<PackageReference Include="ToolGood.Words" Version="3.0.2.6" />
</ItemGroup>
<ItemGroup>

@ -26,6 +26,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json.Linq;
using SqlSugar;
using ToolGood.Words;
namespace CoreCms.Net.Services
@ -38,15 +39,15 @@ namespace CoreCms.Net.Services
private readonly ICoreCmsGoodsCommentRepository _dal;
private readonly IUnitOfWork _unitOfWork;
private readonly IServiceProvider _serviceProvider;
private readonly IToolsServices _toolsServices;
public CoreCmsGoodsCommentServices(IUnitOfWork unitOfWork, ICoreCmsGoodsCommentRepository dal,
IServiceProvider serviceProvider)
IServiceProvider serviceProvider, IToolsServices toolsServices)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
_serviceProvider = serviceProvider;
_toolsServices = toolsServices;
}
/// <summary>
@ -73,10 +74,12 @@ namespace CoreCms.Net.Services
//已经评价或者存在问题
return res;
}
var goodComments = new List<CoreCmsGoodsComment>();
var gid = new List<int>();
foreach (var item in items)
{
//判断此条记录是否是此订单下面的
@ -97,6 +100,9 @@ namespace CoreCms.Net.Services
images = string.Join(",", item.images);
}
//过滤违规字符串
item.textarea = await _toolsServices.IllegalWordsReplace(item.textarea);
var commentModel = new CoreCmsGoodsComment
{
commentId = 0,

@ -8,6 +8,7 @@
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NPOI" Version="2.5.3" />
<PackageReference Include="ToolGood.Words" Version="3.0.2.6" />
</ItemGroup>
<ItemGroup>

@ -7,12 +7,18 @@
* CreateTime: 2021/1/31 21:45:10
* Description:
***********************************************************************/
using System.IO;
using System.Threading.Tasks;
using AutoMapper;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Helper;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.FileProviders;
using ToolGood.Words;
namespace CoreCms.Net.Web.Admin.Controllers
{
@ -22,66 +28,24 @@ namespace CoreCms.Net.Web.Admin.Controllers
//[DisableCors]
public class DemoController : Controller
{
private readonly IRedisOperationRepository _redisOperationRepository;
private readonly ICoreCmsAgentServices _agentServices;
private readonly ICoreCmsDistributionOrderServices _distributionOrderServices;
/// <summary>
/// 构造函数
/// </summary>
public DemoController(IRedisOperationRepository redisOperationRepository, ICoreCmsAgentServices agentServices, ICoreCmsDistributionOrderServices distributionOrderServices)
private readonly IToolsServices _toolsServices;
public DemoController(IToolsServices toolsServices)
{
_redisOperationRepository = redisOperationRepository;
_agentServices = agentServices;
_distributionOrderServices = distributionOrderServices;
_toolsServices = toolsServices;
}
/// <summary>
/// 默认首页
/// </summary>
/// <returns></returns>
public async Task<IActionResult> Index()
{
//var msg = $"这里是一条日志{DateTime.Now}";
//await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.LogingQueue, msg);
//return Content("已结束");
var jm = new WebApiCallBack();
//全部订单
var allOrder = await _distributionOrderServices.QueryChildOrderCountAsync(10, 0);
//一级订单
var firstOrder = await _distributionOrderServices.QueryChildOrderCountAsync(10, 1);
//二级订单
var secondOrder = await _distributionOrderServices.QueryChildOrderCountAsync(10, 2);
//本月订单
var monthOrder = await _distributionOrderServices.QueryChildOrderCountAsync(10, 0, true);
//全部订单金额
var allOrderMoney = await _distributionOrderServices.QueryChildOrderMoneySumAsync(10, 0);
//代购订单金额
var firstOrderMoney = await _distributionOrderServices.QueryChildOrderMoneySumAsync(10, 1);
//推广订单金额
var secondOrderMoney = await _distributionOrderServices.QueryChildOrderMoneySumAsync(10, 2);
//本月订单金额
var monthOrderMoney = await _distributionOrderServices.QueryChildOrderMoneySumAsync(10, 0, true);
jm.status = true;
jm.data = new
{
allOrder,
firstOrder,
secondOrder,
monthOrder,
allOrderMoney,
firstOrderMoney,
secondOrderMoney,
monthOrderMoney
};
return Json(jm);
var t = await _toolsServices.IllegalWordsReplace("测试");
//return Content(t);
return Content(t.ToString());
}
}
}

@ -48,9 +48,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
/// <summary>
/// 构造函数
/// </summary>
/// <param name="webHostEnvironment"></param>
/// <param name="coreCmsGoodsParamsServices"></param>
/// <param name="coreCmsGoodsTypeParamsServices"></param>
public CoreCmsGoodsParamsController(IWebHostEnvironment webHostEnvironment,
ICoreCmsGoodsParamsServices coreCmsGoodsParamsServices)
{

@ -47,6 +47,10 @@
<Compile Include="Controllers\WeChat\CoreCmsUserWeChatMsgTemplateController.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="illegalWord\IllegalKeywords.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
@ -73,6 +77,7 @@
<PackageReference Include="StackExchange.Redis" Version="2.2.4" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.11.1" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.19" />
<PackageReference Include="ToolGood.Words" Version="3.0.2.6" />
</ItemGroup>
<ItemGroup>

@ -530,11 +530,6 @@
演示类
</summary>
</member>
<member name="M:CoreCms.Net.Web.Admin.Controllers.DemoController.#ctor(CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository,CoreCms.Net.IServices.ICoreCmsAgentServices,CoreCms.Net.IServices.ICoreCmsDistributionOrderServices)">
<summary>
构造函数
</summary>
</member>
<member name="M:CoreCms.Net.Web.Admin.Controllers.DemoController.Index">
<summary>
默认首页
@ -1720,9 +1715,6 @@
<summary>
构造函数
</summary>
<param name="webHostEnvironment"></param>
<param name="coreCmsGoodsParamsServices"></param>
<param name="coreCmsGoodsTypeParamsServices"></param>
</member>
<member name="M:CoreCms.Net.Web.Admin.Controllers.CoreCmsGoodsParamsController.GetPageList">
<summary>

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
此文件夹为过滤敏感词存放词库所用。词库内容请保持“|”分隔,并且最后一位不包含“|”

@ -38,6 +38,14 @@
<Content Remove="wwwroot\static\qrCode\weChat\此处会存放用户唯一二维码用于生成带背景海报.txt" />
</ItemGroup>
<ItemGroup>
<None Remove="illegalWord\IllegalKeywords.txt" />
</ItemGroup>
<ItemGroup>
<Content Include="illegalWord\IllegalKeywords.txt" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
@ -65,6 +73,7 @@
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="StackExchange.Redis" Version="2.2.4" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.19" />
<PackageReference Include="ToolGood.Words" Version="3.0.2.6" />
</ItemGroup>
<ItemGroup>

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
此文件夹为过滤敏感词存放词库所用。词库内容请保持“|”分隔,并且最后一位不包含“|”
Loading…
Cancel
Save