Commit 214f9fa8 authored by liudong1993's avatar liudong1993

相亲评论 内容检测

parent d870a3d8
...@@ -27,7 +27,7 @@ namespace Mall.Model.Entity.Education ...@@ -27,7 +27,7 @@ namespace Mall.Model.Entity.Education
public DateTime CreateDate { get; set; } public DateTime CreateDate { get; set; }
/// <summary> /// <summary>
/// 1-文章评论,2-老师动态评论 /// 1-文章评论,2-老师动态评论 , 3-相亲评论
/// </summary> /// </summary>
public int ViolationType { get; set; } public int ViolationType { get; set; }
......
...@@ -14,6 +14,8 @@ using Mall.Repository.User; ...@@ -14,6 +14,8 @@ using Mall.Repository.User;
using Mall.Model.Extend.Statistics; using Mall.Model.Extend.Statistics;
using Mall.Model.Query; using Mall.Model.Query;
using VT.FW.DB; using VT.FW.DB;
using Mall.Model.Entity.Education;
using Mall.Repository.Education;
namespace Mall.Module.User namespace Mall.Module.User
{ {
...@@ -37,6 +39,11 @@ namespace Mall.Module.User ...@@ -37,6 +39,11 @@ namespace Mall.Module.User
/// </summary> /// </summary>
private readonly RB_Member_UserRepository userRepository = new Repository.User.RB_Member_UserRepository(); private readonly RB_Member_UserRepository userRepository = new Repository.User.RB_Member_UserRepository();
/// <summary>
/// 评论违规记录仓储
/// </summary>
private readonly RB_Education_ViolationLogRepository educationViolationLogRepository = new RB_Education_ViolationLogRepository();
#region 发送小程序订阅信息 #region 发送小程序订阅信息
...@@ -996,7 +1003,7 @@ namespace Mall.Module.User ...@@ -996,7 +1003,7 @@ namespace Mall.Module.User
} }
#endregion #endregion
#region #region 评论违规检测
/// <summary> /// <summary>
/// 违规文字检测 /// 违规文字检测
/// </summary> /// </summary>
...@@ -1043,6 +1050,62 @@ namespace Mall.Module.User ...@@ -1043,6 +1050,62 @@ namespace Mall.Module.User
return 0; return 0;
} }
#region 评论违规记录
/// <summary>
/// 获取用户的违规记录
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_ViolationLog> GetViolationLogList(RB_Education_ViolationLog query)
{
return educationViolationLogRepository.GetListRepository(query);
}
/// <summary>
/// 新增用户的违规记录
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetEducationViolationLog(RB_Education_ViolationLog model)
{
return educationViolationLogRepository.Insert(model) > 0;
}
/// <summary>
/// 将用户加入黑名单
/// </summary>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <param name="UserId"></param>
/// <returns></returns>
public bool UpdateUserBlacklist(int TenantId, int MallBaseId, int UserId)
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_Member_User.Blacklist),1}
};
List<WhereHelper> wheres = new List<WhereHelper>()
{
new WhereHelper(){
FiledName=nameof(RB_Member_User.Id),
FiledValue=UserId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_User.TenantId),
FiledValue=TenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_User.MallBaseId),
FiledValue=MallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return userRepository.Update(cols, wheres);
}
#endregion
#endregion #endregion
......
...@@ -16,6 +16,7 @@ using Mall.Module.Miai; ...@@ -16,6 +16,7 @@ using Mall.Module.Miai;
using Mall.Model.Extend.Miai; using Mall.Model.Extend.Miai;
using Mall.Model.Entity.Education; using Mall.Model.Entity.Education;
using Mall.Model.Extend.Education; using Mall.Model.Extend.Education;
using Mall.Module.User;
namespace Mall.WebApi.Controllers.MallBase namespace Mall.WebApi.Controllers.MallBase
{ {
...@@ -27,6 +28,10 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -27,6 +28,10 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
private readonly MiaiModule miaiModule = new MiaiModule(); private readonly MiaiModule miaiModule = new MiaiModule();
private readonly Module.Education.DynamicModule dynamicModule = new Module.Education.DynamicModule(); private readonly Module.Education.DynamicModule dynamicModule = new Module.Education.DynamicModule();
private readonly MiniProgramModule programModule = new MiniProgramModule();
private readonly MiniProgramMsgModule programMsgModule = new MiniProgramMsgModule();
#region 活动版块 #region 活动版块
/// <summary> /// <summary>
/// 获取活动版块列表 /// 获取活动版块列表
...@@ -119,6 +124,11 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -119,6 +124,11 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
var parms = RequestParm; var parms = RequestParm;
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
AppletUserInfo uInfo = UserReidsCache.GetAppletUserBlacklistInfo(userInfo.UserId);
if ((uInfo?.Blacklist ?? 0) == 1)
{
return ApiResult.Failed("已进入黑名单,无法访问");
}
RB_Miai_Activity_Extend demodel = JsonConvert.DeserializeObject<RB_Miai_Activity_Extend>(parms.msg.ToString()); RB_Miai_Activity_Extend demodel = JsonConvert.DeserializeObject<RB_Miai_Activity_Extend>(parms.msg.ToString());
if (demodel.ForumId <= 0) if (demodel.ForumId <= 0)
{ {
...@@ -136,6 +146,45 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -136,6 +146,45 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
return ApiResult.ParamIsNull("请重新选择报名截止日期"); return ApiResult.ParamIsNull("请重新选择报名截止日期");
} }
#region 内容是否违规
try
{
var miniModel = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
int violationNum = programMsgModule.CheckViolation(miniModel, StringHelper.FromUnicodeString(demodel.ActivityTitle));
int violationNum2 = programMsgModule.CheckViolation(miniModel, StringHelper.FromUnicodeString(demodel.Content));
if (violationNum == 0 || violationNum2 == 0)
{
return ApiResult.Failed("评论内容检测失败,请稍后再试");
}
else if (violationNum == 1 || violationNum2 == 1)
{
var violationLogList = programMsgModule.GetViolationLogList(new RB_Education_ViolationLog { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, UserId = userInfo.UserId });
if (violationLogList != null && violationLogList.Any() && violationLogList.Count() >= 1)
{
userInfo = new AppletUserInfo
{
MallBaseId = uInfo.MallBaseId,
UserId = uInfo.UserId,
TenantId = uInfo.TenantId,
Name = uInfo.Name,
SuperiorId = uInfo.SuperiorId,
Blacklist = 1
};
CacheManager.User.UserReidsCache.AppletUserInfoSet(CacheKey.UserModuleCacheKeyConfig.Applet_Blacklist_Info + uInfo.UserId, userInfo, Config.JwtExpirTime);
programMsgModule.UpdateUserBlacklist(userInfo.TenantId, userInfo.MallBaseId, userInfo.UserId);
}
programMsgModule.SetEducationViolationLog(new RB_Education_ViolationLog { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, UserId = userInfo.UserId, ViolationType = 3, CreateDate = System.DateTime.Now });
return ApiResult.Failed("评论存在违规内容,若多次发布违规内容将被拉黑");
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SetActivityInfo");
return ApiResult.Failed("评论内容检测失败,请稍后再试");
}
#endregion
demodel.ImageList ??= new List<string>(); demodel.ImageList ??= new List<string>();
demodel.Images = JsonConvert.SerializeObject(demodel.ImageList); demodel.Images = JsonConvert.SerializeObject(demodel.ImageList);
demodel.TenantId = userInfo.TenantId; demodel.TenantId = userInfo.TenantId;
...@@ -271,6 +320,11 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -271,6 +320,11 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
var parms = RequestParm; var parms = RequestParm;
var userInfo = AppletUserInfo; var userInfo = AppletUserInfo;
AppletUserInfo uInfo = UserReidsCache.GetAppletUserBlacklistInfo(userInfo.UserId);
if ((uInfo?.Blacklist ?? 0) == 1)
{
return ApiResult.Failed("已进入黑名单,无法访问");
}
RB_Miai_ActivityDiscuss_Extend demodel = JsonConvert.DeserializeObject<RB_Miai_ActivityDiscuss_Extend>(parms.msg.ToString()); RB_Miai_ActivityDiscuss_Extend demodel = JsonConvert.DeserializeObject<RB_Miai_ActivityDiscuss_Extend>(parms.msg.ToString());
if (demodel.ActivityId <= 0) if (demodel.ActivityId <= 0)
{ {
...@@ -281,6 +335,43 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -281,6 +335,43 @@ namespace Mall.WebApi.Controllers.MallBase
return ApiResult.ParamIsNull("请传递内容"); return ApiResult.ParamIsNull("请传递内容");
} }
#region 内容是否违规
try
{
var miniModel = programModule.GetMiniProgramModule(new Model.Extend.User.RB_MiniProgram_Extend { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId });
int violationNum = programMsgModule.CheckViolation(miniModel, StringHelper.FromUnicodeString(demodel.Content));
if (violationNum == 0)
{
return ApiResult.Failed("评论内容检测失败,请稍后再试");
}
else if (violationNum == 1)
{
var violationLogList = programMsgModule.GetViolationLogList(new RB_Education_ViolationLog { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, UserId = userInfo.UserId });
if (violationLogList != null && violationLogList.Any() && violationLogList.Count() >= 1)
{
userInfo = new AppletUserInfo
{
MallBaseId = uInfo.MallBaseId,
UserId = uInfo.UserId,
TenantId = uInfo.TenantId,
Name = uInfo.Name,
SuperiorId = uInfo.SuperiorId,
Blacklist = 1
};
CacheManager.User.UserReidsCache.AppletUserInfoSet(CacheKey.UserModuleCacheKeyConfig.Applet_Blacklist_Info + uInfo.UserId, userInfo, Config.JwtExpirTime);
programMsgModule.UpdateUserBlacklist(userInfo.TenantId, userInfo.MallBaseId, userInfo.UserId);
}
programMsgModule.SetEducationViolationLog(new RB_Education_ViolationLog { TenantId = userInfo.TenantId, MallBaseId = userInfo.MallBaseId, UserId = userInfo.UserId, ViolationType = 3, CreateDate = System.DateTime.Now });
return ApiResult.Failed("评论存在违规内容,若多次发布违规内容将被拉黑");
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "SetActivityInfo");
return ApiResult.Failed("评论内容检测失败,请稍后再试");
}
#endregion
demodel.ImageList ??= new List<string>(); demodel.ImageList ??= new List<string>();
demodel.Images = JsonConvert.SerializeObject(demodel.ImageList); demodel.Images = JsonConvert.SerializeObject(demodel.ImageList);
demodel.TenantId = userInfo.TenantId; demodel.TenantId = userInfo.TenantId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment