mirror of https://gitee.com/CoreUnion/CoreShop.git
!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
parent
4b7c9485ce
commit
56b9c45ef4
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
此文件夹为过滤敏感词存放词库所用。词库内容请保持“|”分隔,并且最后一位不包含“|”
|
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
|
||||
此文件夹为过滤敏感词存放词库所用。词库内容请保持“|”分隔,并且最后一位不包含“|”
|
Loading…
Reference in New Issue