-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
PostPublicQueryService.java
63 lines (56 loc) · 2.14 KB
/
PostPublicQueryService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package run.halo.app.theme.finders;
import java.util.Comparator;
import java.util.Objects;
import java.util.function.Predicate;
import org.springframework.lang.NonNull;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.content.Post;
import run.halo.app.extension.ListResult;
import run.halo.app.theme.ReactivePostContentHandler;
import run.halo.app.theme.finders.vo.ContentVo;
import run.halo.app.theme.finders.vo.ListedPostVo;
import run.halo.app.theme.finders.vo.PostVo;
public interface PostPublicQueryService {
Predicate<Post> FIXED_PREDICATE = post -> post.isPublished()
&& Objects.equals(false, post.getSpec().getDeleted())
&& Post.VisibleEnum.PUBLIC.equals(post.getSpec().getVisible());
/**
* Lists posts page by predicate and comparator.
*
* @param page page number
* @param size page size
* @param postPredicate post predicate
* @param comparator post comparator
* @return list result
*/
Mono<ListResult<ListedPostVo>> list(Integer page, Integer size,
Predicate<Post> postPredicate,
Comparator<Post> comparator);
/**
* Converts post to listed post vo.
*
* @param post post must not be null
* @return listed post vo
*/
Mono<ListedPostVo> convertToListedVo(@NonNull Post post);
/**
* Converts {@link Post} to post vo and populate post content by the given snapshot name.
* <p> This method will get post content by {@code snapshotName} and try to find
* {@link ReactivePostContentHandler}s to extend the content</p>
*
* @param post post must not be null
* @param snapshotName snapshot name must not be blank
* @return converted post vo
*/
Mono<PostVo> convertToVo(Post post, String snapshotName);
/**
* Gets post content by post name.
* <p> This method will get post released content by post name and try to find
* {@link ReactivePostContentHandler}s to extend the content</p>
*
* @param postName post name must not be blank
* @return post content for theme-side
* @see ReactivePostContentHandler
*/
Mono<ContentVo> getContent(String postName);
}