🐛 修复更新文章后,文章摘要丢失的问题

pull/69/head
ruibaby 2018-12-09 21:07:42 +08:00
parent e30b01f858
commit bd43112a3e
2 changed files with 14 additions and 1 deletions

View File

@ -227,7 +227,7 @@ public class AdminController extends BaseController {
} }
/** /**
* * Halo
* *
* @return admin/admin_halo * @return admin/admin_halo
*/ */

View File

@ -239,6 +239,19 @@ public class PostController extends BaseController {
if (null == post.getPostDate()) { if (null == post.getPostDate()) {
post.setPostDate(new Date()); post.setPostDate(new Date());
} }
//摘要字数
int postSummary = 50;
if (StrUtil.isNotEmpty(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()))) {
postSummary = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()));
}
//设置文章摘要
String summaryText = StrUtil.cleanBlank(HtmlUtil.cleanHtmlTag(post.getPostContent()));
if (summaryText.length() > postSummary) {
String summary = summaryText.substring(0, postSummary);
post.setPostSummary(summary);
} else {
post.setPostSummary(summaryText);
}
post = postService.buildCategoriesAndTags(post, cateList, tagList); post = postService.buildCategoriesAndTags(post, cateList, tagList);
post = postService.save(post); post = postService.save(post);
if (null != post) { if (null != post) {