Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
f040f118
Commit
f040f118
authored
Sep 08, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文本查重
parent
4ff6e293
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+5
-5
ThemeTextCheckService.java
...va/com/tanpu/community/service/ThemeTextCheckService.java
+3
-0
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+14
-0
No files found.
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
f040f118
...
@@ -209,16 +209,16 @@ public class ThemeManager {
...
@@ -209,16 +209,16 @@ public class ThemeManager {
// 校验参数
// 校验参数
checkAttachment
(
req
.
getContent
());
checkAttachment
(
req
.
getContent
());
// 文本查重
if
(
themeTextCheckService
.
checkDuplicate
(
ConvertUtil
.
convertThemeText
(
JsonUtil
.
toJson
(
req
.
getContent
()))))
{
return
CommonResp
.
error
(
ErrorCodeConstant
.
THEME_TEXT_DUPLICATE
.
getCode
(),
ErrorCodeConstant
.
THEME_TEXT_DUPLICATE
.
getMsg
());
}
// 保存主题表
// 保存主题表
ThemeEntity
themeEntity
=
new
ThemeEntity
();
ThemeEntity
themeEntity
=
new
ThemeEntity
();
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
BeanUtils
.
copyProperties
(
req
,
themeEntity
);
themeEntity
.
setAuthorId
(
userId
);
themeEntity
.
setAuthorId
(
userId
);
// 文本查重
if
(
themeTextCheckService
.
checkDuplicate
(
ConvertUtil
.
convert
(
themeEntity
).
getTextContent
()))
{
throw
new
BizException
(
"圈子里已存在相似内容,请勿重复发布"
);
}
// 腾讯云敏感词校验
// 腾讯云敏感词校验
checkContent
(
req
);
checkContent
(
req
);
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
themeEntity
.
setContent
(
JsonUtil
.
toJson
(
req
.
getContent
()));
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeTextCheckService.java
View file @
f040f118
...
@@ -49,6 +49,9 @@ public class ThemeTextCheckService {
...
@@ -49,6 +49,9 @@ public class ThemeTextCheckService {
}
}
public
boolean
checkDuplicate
(
String
content
)
{
public
boolean
checkDuplicate
(
String
content
)
{
if
(
content
.
length
()<
15
){
return
false
;
}
content
=
content
.
replaceAll
(
"[,。!? ]"
,
"。"
);
content
=
content
.
replaceAll
(
"[,。!? ]"
,
"。"
);
String
[]
split
=
content
.
split
(
"。"
);
String
[]
split
=
content
.
split
(
"。"
);
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
f040f118
...
@@ -71,6 +71,20 @@ public class ConvertUtil {
...
@@ -71,6 +71,20 @@ public class ConvertUtil {
return
themeEntities
.
stream
().
map
(
ConvertUtil:
:
themeEntityToQo
).
collect
(
Collectors
.
toList
());
return
themeEntities
.
stream
().
map
(
ConvertUtil:
:
themeEntityToQo
).
collect
(
Collectors
.
toList
());
}
}
// 抽取文本内容
public
static
String
convertThemeText
(
String
content
)
{
List
<
ThemeContentQo
>
themeContentQos
=
JsonUtil
.
toBean
(
content
,
new
TypeReference
<
List
<
ThemeContentQo
>>()
{
});
StringBuilder
sb
=
new
StringBuilder
();
themeContentQos
.
stream
().
filter
(
q
->
RelTypeEnum
.
TEXT
.
type
.
equals
(
q
.
getType
())).
forEach
(
q
->
{
sb
.
append
(
q
.
getValue
());
});
return
sb
.
toString
();
}
public
static
ESThemeQo
convert
(
ThemeEntity
entity
)
{
public
static
ESThemeQo
convert
(
ThemeEntity
entity
)
{
ESThemeQo
qo
=
new
ESThemeQo
();
ESThemeQo
qo
=
new
ESThemeQo
();
BeanUtils
.
copyProperties
(
entity
,
qo
);
BeanUtils
.
copyProperties
(
entity
,
qo
);
...
...
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