From 55ab7815a9151d07ab0248e462aee16c9d2f53a9 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Mon, 18 Mar 2019 21:40:15 +0800 Subject: [PATCH] v1.0 --- .../ryanc/halo/service/CategoryService.java | 6 ++++ .../cc/ryanc/halo/service/PostService.java | 28 +++++++++++++++---- .../cc/ryanc/halo/service/TagService.java | 7 +++++ .../service/impl/CategoryServiceImpl.java | 10 +++++++ .../halo/service/impl/PostServiceImpl.java | 28 +++++++++++++++++++ .../halo/service/impl/TagServiceImpl.java | 10 +++++++ 6 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/main/java/cc/ryanc/halo/service/CategoryService.java b/src/main/java/cc/ryanc/halo/service/CategoryService.java index f84c51527..5830f3c45 100755 --- a/src/main/java/cc/ryanc/halo/service/CategoryService.java +++ b/src/main/java/cc/ryanc/halo/service/CategoryService.java @@ -10,4 +10,10 @@ import cc.ryanc.halo.service.base.CrudService; */ public interface CategoryService extends CrudService { + /** + * Remove category and relationship + * + * @param id id + */ + void remove(Integer id); } diff --git a/src/main/java/cc/ryanc/halo/service/PostService.java b/src/main/java/cc/ryanc/halo/service/PostService.java index cb8a257e9..3744a22e1 100755 --- a/src/main/java/cc/ryanc/halo/service/PostService.java +++ b/src/main/java/cc/ryanc/halo/service/PostService.java @@ -1,7 +1,9 @@ package cc.ryanc.halo.service; import cc.ryanc.halo.model.dto.post.PostSimpleOutputDTO; +import cc.ryanc.halo.model.entity.Category; import cc.ryanc.halo.model.entity.Post; +import cc.ryanc.halo.model.entity.Tag; import cc.ryanc.halo.model.enums.PostStatus; import cc.ryanc.halo.model.enums.PostType; import cc.ryanc.halo.service.base.CrudService; @@ -9,6 +11,8 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.lang.NonNull; +import java.util.List; + /** * Post service. * @@ -17,11 +21,26 @@ import org.springframework.lang.NonNull; */ public interface PostService extends CrudService { + /** + * Save post with tags and categories + * + * @param post post + * @param tags tags + * @param categories categories + * @return saved post + */ + Post save(Post post, List tags, List categories); + + /** + * Remove post and relationship + * @param id id + */ + void remove(Integer id); + /** * Lists latest posts. * * @param top top number must not be less than 0 - * * @return latest posts */ @NonNull @@ -30,10 +49,9 @@ public interface PostService extends CrudService { /** * List by status and type * - * @param status status - * @param type type + * @param status status + * @param type type * @param pageable pageable - * * @return Page */ @NonNull @@ -43,7 +61,7 @@ public interface PostService extends CrudService { * Count posts by status and type * * @param status status - * @param type type + * @param type type * @return posts count */ Long countByStatus(PostStatus status, PostType type); diff --git a/src/main/java/cc/ryanc/halo/service/TagService.java b/src/main/java/cc/ryanc/halo/service/TagService.java index d4c59f55b..c57fde9ef 100644 --- a/src/main/java/cc/ryanc/halo/service/TagService.java +++ b/src/main/java/cc/ryanc/halo/service/TagService.java @@ -10,4 +10,11 @@ import cc.ryanc.halo.service.base.CrudService; * @author johnniang */ public interface TagService extends CrudService { + + /** + * Remove tag and relationship + * + * @param id id + */ + void remove(Integer id); } diff --git a/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java index 08307dadd..1983a431e 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/CategoryServiceImpl.java @@ -21,4 +21,14 @@ public class CategoryServiceImpl extends AbstractCrudService super(categoryRepository); this.categoryRepository = categoryRepository; } + + /** + * Remove category and relationship + * + * @param id id + */ + @Override + public void remove(Integer id) { + // TODO 删除分类,以及和文章的对应关系 + } } diff --git a/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java index 848cd78b1..68dfd07f1 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/PostServiceImpl.java @@ -1,7 +1,9 @@ package cc.ryanc.halo.service.impl; import cc.ryanc.halo.model.dto.post.PostSimpleOutputDTO; +import cc.ryanc.halo.model.entity.Category; import cc.ryanc.halo.model.entity.Post; +import cc.ryanc.halo.model.entity.Tag; import cc.ryanc.halo.model.enums.PostStatus; import cc.ryanc.halo.model.enums.PostType; import cc.ryanc.halo.repository.PostRepository; @@ -14,6 +16,8 @@ import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.util.List; + /** * Post service implementation. * @@ -30,6 +34,30 @@ public class PostServiceImpl extends AbstractCrudService implemen this.postRepository = postRepository; } + /** + * Save post with tags and categories + * + * @param post post + * @param tags tags + * @param categories categories + * @return saved post + */ + @Override + public Post save(Post post, List tags, List categories) { + // TODO 保存文章以及对应标签和分类 + return null; + } + + /** + * Remove post and relationship + * + * @param id id + */ + @Override + public void remove(Integer id) { + // TODO 删除文章以及关联关系 + } + @Override public Page listLatest(int top) { Assert.isTrue(top > 0, "Top number must not be less than 0"); diff --git a/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java b/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java index 10e849abe..f149acbf6 100644 --- a/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java +++ b/src/main/java/cc/ryanc/halo/service/impl/TagServiceImpl.java @@ -21,4 +21,14 @@ public class TagServiceImpl extends AbstractCrudService implements super(tagRepository); this.tagRepository = tagRepository; } + + /** + * Remove tag and relationship + * + * @param id id + */ + @Override + public void remove(Integer id) { + // TODO 删除标签,以及对应的文章关系 + } }