Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mall.oytour.com
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄奎
mall.oytour.com
Commits
d1aa84cc
Commit
d1aa84cc
authored
Jan 18, 2021
by
吴春
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交评论违规加入黑名单
parent
af7f1f37
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
282 additions
and
9 deletions
+282
-9
RB_Education_ViolationLog.cs
Mall.Model/Entity/Education/RB_Education_ViolationLog.cs
+43
-0
RB_MiniProgram.cs
Mall.Model/Entity/User/RB_MiniProgram.cs
+5
-0
EducationModule.cs
Mall.Module.Education/EducationModule.cs
+68
-8
MiniProgramMsgModule.cs
Mall.Module.User/MiniProgramMsgModule.cs
+51
-1
RB_Education_ViolationLogRepository.cs
...pository/Education/RB_Education_ViolationLogRepository.cs
+41
-0
AppletEducationController.cs
...WebApi/Controllers/Education/AppletEducationController.cs
+74
-0
No files found.
Mall.Model/Entity/Education/RB_Education_ViolationLog.cs
0 → 100644
View file @
d1aa84cc
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
VT.FW.DB
;
namespace
Mall.Model.Entity.Education
{
/// <summary>
/// 评论违规记录表
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Education_ViolationLog
{
public
int
ID
{
get
;
set
;
}
/// <summary>
/// 商户id
/// </summary>
public
int
TenantId
{
get
;
set
;
}
/// <summary>
/// 小程序id
/// </summary>
public
int
MallBaseId
{
get
;
set
;
}
public
DateTime
CreateDate
{
get
;
set
;
}
/// <summary>
/// 1-文章评论,2-老师动态评论
/// </summary>
public
int
ViolationType
{
get
;
set
;
}
/// <summary>
/// 用户id
/// </summary>
public
int
?
UserId
{
get
;
set
;
}
}
}
Mall.Model/Entity/User/RB_MiniProgram.cs
View file @
d1aa84cc
...
...
@@ -444,6 +444,11 @@ namespace Mall.Model.Entity.User
/// 老师发动态后给关注的人发消息
/// </summary>
public
string
EducationDynamicTpl
{
get
;
set
;
}
/// <summary>
/// 评论关键字违规次数
/// </summary>
public
int
ViolationNum
{
get
;
set
;
}
}
...
...
Mall.Module.Education/EducationModule.cs
View file @
d1aa84cc
...
...
@@ -132,7 +132,10 @@ namespace Mall.Module.Education
/// 启动页仓储
/// </summary>
private
readonly
RB_Education_StartUpRepository
educationStartUpRepository
=
new
RB_Education_StartUpRepository
();
/// <summary>
/// 评论违规记录仓储
/// </summary>
private
readonly
RB_Education_ViolationLogRepository
educationViolationLogRepository
=
new
RB_Education_ViolationLogRepository
();
#
region
课程管理
...
...
@@ -3153,7 +3156,7 @@ namespace Mall.Module.Education
/// <returns></returns>
public
List
<
RB_Education_FollowTeacher_Extend
>
GetFollowUserList
(
RB_Education_FollowTeacher_Extend
query
)
{
List
<
RB_Education_FollowTeacher_Extend
>
list
=
followTeacherRepository
.
GetFollowUserList
(
query
);
List
<
RB_Education_FollowTeacher_Extend
>
list
=
followTeacherRepository
.
GetFollowUserList
(
query
);
return
list
;
}
...
...
@@ -3275,5 +3278,62 @@ namespace Mall.Module.Education
}
}
#
endregion
#
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
member_UserRepository
.
Update
(
cols
,
wheres
);
}
#
endregion
}
}
Mall.Module.User/MiniProgramMsgModule.cs
View file @
d1aa84cc
...
...
@@ -891,7 +891,8 @@ namespace Mall.Module.User
{
return
true
;
}
else
{
else
{
return
false
;
}
}
...
...
@@ -900,6 +901,55 @@ namespace Mall.Module.User
#
endregion
#
region
/// <summary>
/// 违规文字检测
/// </summary>
/// <param name="TenantId"></param>
/// <param name="MallBaseId"></param>
/// <returns></returns>
public
int
CheckViolation
(
RB_MiniProgram_Extend
model
,
string
content
)
{
var
appletWeChatModel
=
programRepository
.
GetListRepository
(
model
).
FirstOrDefault
();
string
token
=
WeiXinReidsCache
.
Get
(
appletWeChatModel
.
MiniAppId
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Mall
.
Common
.
Pay
.
WeChatPat
.
TokenHelper
.
GetLXYToken
(
token
,
appletWeChatModel
.
MiniAppId
,
appletWeChatModel
.
MiniAppSecret
);
System
.
Threading
.
Tasks
.
Task
.
Run
(()
=>
WeiXinReidsCache
.
Set
(
appletWeChatModel
.
MiniAppId
,
token
));
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
return
0
;
}
string
wenXinResult
=
string
.
Empty
;
if
(!
string
.
IsNullOrWhiteSpace
(
token
))
{
string
Url
=
"https://api.weixin.qq.com/wxa/msg_sec_check?access_token="
+
token
;
var
postdata
=
new
{
content
=
content
};
wenXinResult
=
HttpHelper
.
HttpPost
(
Url
,
JsonHelper
.
Serialize
(
postdata
),
""
);
LogHelper
.
WriteInfo
(
"下单成功发送订阅消息:"
+
wenXinResult
);
JObject
jo
=
(
JObject
)
JsonConvert
.
DeserializeObject
(
wenXinResult
);
int
errcode
=
Convert
.
ToInt32
(
jo
[
"errcode"
].
ToString
());
if
(
errcode
==
0
)
{
//成功
return
2
;
}
else
{
LogHelper
.
WriteInfo
(
string
.
Format
(
"CheckViolation:wenXinResult:{0}"
,
wenXinResult
));
return
1
;
}
}
return
0
;
}
#
endregion
}
}
Mall.Repository/Education/RB_Education_ViolationLogRepository.cs
0 → 100644
View file @
d1aa84cc
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Mall.Model.Entity.Education
;
namespace
Mall.Repository.Education
{
/// <summary>
/// 评论违规记录
/// </summary>
public
class
RB_Education_ViolationLogRepository
:
BaseRepository
<
RB_Education_ViolationLog
>
{
/// <summary>
/// 获取用户的违规记录
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public
List
<
RB_Education_ViolationLog
>
GetListRepository
(
RB_Education_ViolationLog
query
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
$" SELECT * FROM RB_Education_ViolationLog WHERE 1=1"
);
if
(
query
!=
null
)
{
if
(
query
.
TenantId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Education_ViolationLog
.
TenantId
)}
=
{
query
.
TenantId
}
"
);
}
if
(
query
.
UserId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Education_ViolationLog
.
UserId
)}
=
{
query
.
UserId
}
"
);
}
if
(
query
.
MallBaseId
>
0
)
{
builder
.
Append
(
$" AND
{
nameof
(
RB_Education_ViolationLog
.
MallBaseId
)}
=
{
query
.
MallBaseId
}
"
);
}
}
return
Get
<
RB_Education_ViolationLog
>(
builder
.
ToString
()).
ToList
();
}
}
}
Mall.WebApi/Controllers/Education/AppletEducationController.cs
View file @
d1aa84cc
...
...
@@ -760,6 +760,42 @@ namespace Mall.WebApi.Controllers.Education
return
ApiResult
.
ParamIsNull
(
"资讯不允许留言"
);
}
#
region
内容是否违规
try
{
//获取订阅消息
var
miniModel
=
programModule
.
GetMiniProgramModule
(
new
RB_MiniProgram_Extend
{
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
});
int
violationNum
=
new
MiniProgramMsgModule
().
CheckViolation
(
miniModel
,
demodel
.
Content
);
if
(
violationNum
==
0
)
{
return
ApiResult
.
Failed
(
"评论内容检测失败,请稍后再试"
);
}
else
if
(
violationNum
==
1
)
{
var
violationLogList
=
educationModule
.
GetViolationLogList
(
new
RB_Education_ViolationLog
{
TenantId
=
uInfo
.
TenantId
,
MallBaseId
=
uInfo
.
MallBaseId
,
UserId
=
uInfo
.
UserId
});
if
(
violationLogList
!=
null
&&
violationLogList
.
Any
()
&&
(
violationLogList
.
Count
()
+
1
)
>=
miniModel
.
ViolationNum
)
{
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
);
educationModule
.
UpdateUserBlacklist
(
uInfo
.
TenantId
,
uInfo
.
MallBaseId
,
uInfo
.
UserId
);
}
educationModule
.
SetEducationViolationLog
(
new
RB_Education_ViolationLog
{
TenantId
=
uInfo
.
TenantId
,
MallBaseId
=
uInfo
.
MallBaseId
,
UserId
=
uInfo
.
UserId
,
ViolationType
=
1
,
CreateDate
=
System
.
DateTime
.
Now
});
return
ApiResult
.
Failed
(
"评论存在违规内容,若多次发布违规内容将被拉黑"
);
}
}
catch
(
Exception
ex
)
{
return
ApiResult
.
Failed
(
"评论内容检测失败,请稍后再试"
);
}
#
endregion
demodel
.
CommentGrade
??=
Common
.
Enum
.
Goods
.
GoodsCommentTypeEnum
.
Praise
;
demodel
.
CommentScore
??=
5
;
demodel
.
CommentImage
=
""
;
...
...
@@ -1384,6 +1420,7 @@ namespace Mall.WebApi.Controllers.Education
article
.
FileType
=
0
;
}
article
.
Content
=
StringHelper
.
ToUnicodeString
(
article
.
Content
);
article
.
Status
=
0
;
if
(
dynamicModule
.
PublishDynamic
(
article
))
{
...
...
@@ -1551,6 +1588,43 @@ namespace Mall.WebApi.Controllers.Education
return
ApiResult
.
Failed
(
str
);
}
comment
.
Content
=
StringHelper
.
ToUnicodeString
(
comment
.
Content
);
#
region
内容是否违规
try
{
var
miniModel
=
programModule
.
GetMiniProgramModule
(
new
RB_MiniProgram_Extend
{
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
});
int
violationNum
=
new
MiniProgramMsgModule
().
CheckViolation
(
miniModel
,
StringHelper
.
FromUnicodeString
(
comment
.
Content
));
if
(
violationNum
==
0
)
{
return
ApiResult
.
Failed
(
"评论内容检测失败,请稍后再试"
);
}
else
if
(
violationNum
==
1
)
{
var
violationLogList
=
educationModule
.
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
);
educationModule
.
UpdateUserBlacklist
(
userInfo
.
TenantId
,
userInfo
.
MallBaseId
,
userInfo
.
UserId
);
}
educationModule
.
SetEducationViolationLog
(
new
RB_Education_ViolationLog
{
TenantId
=
userInfo
.
TenantId
,
MallBaseId
=
userInfo
.
MallBaseId
,
UserId
=
userInfo
.
UserId
,
ViolationType
=
2
,
CreateDate
=
System
.
DateTime
.
Now
});
return
ApiResult
.
Failed
(
"评论存在违规内容,若多次发布违规内容将被拉黑"
);
}
}
catch
(
Exception
ex
)
{
return
ApiResult
.
Failed
(
"评论内容检测失败,请稍后再试"
);
}
#
endregion
comment
.
Status
=
0
;
comment
.
CreateTime
=
DateTime
.
Now
;
comment
.
UserId
=
userInfo
.
UserId
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment