修改导入markdown文件时,slug为空时初始化赋值

pull/192/head
wuzhi1234 2019-06-08 23:14:46 +08:00
parent 61caec9403
commit cc5a3e87e0
1 changed files with 26 additions and 3 deletions

View File

@ -19,7 +19,11 @@ import run.halo.app.event.logger.LogEvent;
import run.halo.app.event.post.PostVisitEvent;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.dto.TagDTO;
import run.halo.app.model.entity.*;
import run.halo.app.model.entity.Category;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostCategory;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.entity.Tag;
import run.halo.app.model.enums.LogType;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.model.params.PostQuery;
@ -28,8 +32,15 @@ import run.halo.app.model.vo.ArchiveYearVO;
import run.halo.app.model.vo.PostDetailVO;
import run.halo.app.model.vo.PostListVO;
import run.halo.app.repository.PostRepository;
import run.halo.app.service.*;
import run.halo.app.service.CategoryService;
import run.halo.app.service.OptionService;
import run.halo.app.service.PostCategoryService;
import run.halo.app.service.PostCommentService;
import run.halo.app.service.PostService;
import run.halo.app.service.PostTagService;
import run.halo.app.service.TagService;
import run.halo.app.utils.DateUtils;
import run.halo.app.utils.HaloUtils;
import run.halo.app.utils.MarkdownUtils;
import run.halo.app.utils.ServiceUtils;
import run.halo.app.utils.SlugUtils;
@ -37,7 +48,17 @@ import run.halo.app.utils.SlugUtils;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import java.util.*;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -327,6 +348,8 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
tag = new Tag();
tag.setName(ele);
tag.setSlugName(SlugUtils.slugify(ele));
String slugName = SlugUtils.slugify(ele);
tag.setSlugName(HaloUtils.initializeUrlIfBlank(slugName));
tag = tagService.create(tag);
}
tagIds.add(tag.getId());