Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
8407e3ca
Commit
8407e3ca
authored
Feb 06, 2020
by
Author name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2.6 博客自动提取摘要
parent
7bd0cc7d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
src/main/java/cn/meteor/beyondclouds/modules/blog/form/BlogForm.java
+1
-3
src/main/java/cn/meteor/beyondclouds/modules/blog/service/impl/BlogServiceImpl.java
+13
-1
No files found.
src/main/java/cn/meteor/beyondclouds/modules/blog/form/BlogForm.java
View file @
8407e3ca
...
@@ -28,9 +28,7 @@ public class BlogForm {
...
@@ -28,9 +28,7 @@ public class BlogForm {
@NullOrNotBlank
(
message
=
"请传入有效的原文链接"
)
@NullOrNotBlank
(
message
=
"请传入有效的原文链接"
)
private
String
originLink
;
private
String
originLink
;
@NotNull
(
message
=
"摘要不能为空"
,
groups
=
InsertGroup
.
class
)
@NullOrNotBlank
(
message
=
"请传入有效的摘要"
)
@NotEmpty
(
message
=
"摘要不能为空"
,
groups
=
InsertGroup
.
class
)
@NullOrNotBlank
(
message
=
"请传入有效的摘要"
,
groups
=
UpdateGroup
.
class
)
private
String
blogAbstract
;
private
String
blogAbstract
;
@NotNull
(
message
=
"博客类型不能为空"
,
groups
=
InsertGroup
.
class
)
@NotNull
(
message
=
"博客类型不能为空"
,
groups
=
InsertGroup
.
class
)
...
...
src/main/java/cn/meteor/beyondclouds/modules/blog/service/impl/BlogServiceImpl.java
View file @
8407e3ca
...
@@ -102,7 +102,19 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
...
@@ -102,7 +102,19 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
blog
.
setAllowForward
(
false
);
blog
.
setAllowForward
(
false
);
}
}
//如果没有手动添加摘要则自动从内容里摘取20字
if
(
null
==
blog
.
getBlogAbstract
())
{
//去除内容中的HTML标签
String
con
=
""
;
con
=
content
.
replaceAll
(
"<[^>]+>|</[^>]+>"
,
""
);
con
=
con
.
replaceAll
(
" "
,
""
);
//判断内容是否有20个字
if
(
con
.
length
()
<=
20
)
{
blog
.
setBlogAbstract
(
con
+
"..."
);
}
else
{
blog
.
setBlogAbstract
(
con
.
substring
(
0
,
20
)
+
"..."
);
}
}
//1.判断博客类型是否存在
//1.判断博客类型是否存在
BlogCategory
blogCategory
=
blogCategoryService
.
getById
(
blog
.
getCategoryId
());
BlogCategory
blogCategory
=
blogCategoryService
.
getById
(
blog
.
getCategoryId
());
if
(
null
==
blogCategory
)
{
if
(
null
==
blogCategory
)
{
...
...
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