本文整理了Java中com.example.demo.Post
类的一些代码示例,展示了Post
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Post
类的具体详情如下:
包路径:com.example.demo.Post
类名称:Post
暂无
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> save(Post post) {
long id = DATA.size() + 1;
Post saved = Post.builder().id(id).title(post.getTitle()).content(post.getContent()).build();
DATA.add(saved);
return Mono.just(saved);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> update(Long id, Post post) {
Post updated = data.get(id);
updated.setTitle(post.getTitle());
updated.setContent(post.getContent());
data.put(id, updated);
return Mono.just(updated);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> save(Post post) {
if (post.getId() != null) {
String id = UUID.randomUUID().toString();
post.setId(id);
}
return template.<String, Post>opsForHash().put("posts", post.getId(), post)
.log()
.map(p -> post);
}
代码示例来源:origin: hantsy/angular-spring-reactive-sample
private Flux<Post> filterPublishedPostsByKeyword(String q) {
return this.posts.findAll()
.filter(p -> Post.Status.PUBLISHED == p.getStatus())
.filter(
p -> Optional.ofNullable(q)
.map(key -> p.getTitle().contains(key) || p.getContent().contains(key))
.orElse(true)
);
}
代码示例来源:origin: hantsy/spring-reactive-sample
@PostConstruct
public void initPosts() {
log.info("initializing posts data...");
this.posts.deleteAll();
Stream.of("Post one", "Post two").forEach(
title -> this.posts.save(Post.builder().title(title).content("content of " + title).build())
);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Single<Integer> save(Post post) {
return this.db.update("insert into posts(title, content) values(?, ?)")
.parameter(post.getTitle())
.parameter(post.getContent())
.returnGeneratedKeys()
.getAs(Integer.class)
.toSingle();
}
代码示例来源:origin: hantsy/spring-reactive-sample
public Mono<ServerResponse> create(ServerRequest req) {
return req.bodyToMono(Post.class)
.flatMap(post -> this.posts.save(post))
.flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build());
}
代码示例来源:origin: hantsy/spring-reactive-sample
@EventListener(ContextRefreshedEvent.class)
public void initPosts() {
log.info("initializing posts data...");
Stream.of("Post one", "Post two").forEach(
title -> this.posts.save(Post.builder().title(title).content("content of " + title).build())
.subscribe()
);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Single<Post> findById(Long id) {
return findAll().filter(p -> Objects.equals(p.getId(), id)).single().toSingle();
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> update(Long id, Post post) {
Post updated = data.get(id);
updated.setTitle(post.getTitle());
updated.setContent(post.getContent());
data.put(id, updated);
return Mono.just(updated);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> save(Post post) {
long id = DATA.size() + 1;
Post saved = Post.builder().id(id).title(post.getTitle()).content(post.getContent()).build();
DATA.add(saved);
return Mono.just(saved);
}
代码示例来源:origin: hantsy/spring-reactive-sample
public PostRepository() {
Stream.of("post one", "post two").forEach(title -> {
Long id = this.nextId();
data.put(id, Post.builder().id(id).title(title).content("content of " + title).build());
});
}
代码示例来源:origin: hantsy/spring-reactive-sample
public Mono<ServerResponse> create(ServerRequest req) {
return req.bodyToMono(Post.class)
.flatMap(post -> this.posts.save(post))
.flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build());
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> update(Long id, Post post) {
Post updated = data.get(id);
updated.setTitle(post.getTitle());
updated.setContent(post.getContent());
data.put(id, updated);
return Mono.just(updated);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> save(Post post) {
Long id = nextId();
Post saved = Post.builder().id(id).title(post.getTitle()).content(post.getContent()).build();
data.put(id, saved);
return Mono.just(saved);
}
代码示例来源:origin: hantsy/spring-reactive-sample
public PostRepository() {
Stream.of("post one", "post two").forEach(title -> {
Long id = this.nextId();
data.put(id, Post.builder().id(id).title(title).content("content of " + title).build());
});
}
代码示例来源:origin: hantsy/spring-reactive-sample
public Mono<ServerResponse> create(ServerRequest req) {
return req.bodyToMono(Post.class)
.flatMap(post -> this.posts.save(post))
.flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build());
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> update(Long id, Post post) {
Post updated = data.get(id);
updated.setTitle(post.getTitle());
updated.setContent(post.getContent());
data.put(id, updated);
return Mono.just(updated);
}
代码示例来源:origin: hantsy/spring-reactive-sample
Mono<Post> save(Post post) {
Long id = nextId();
Post saved = Post.builder().id(id).title(post.getTitle()).content(post.getContent()).build();
data.put(id, saved);
return Mono.just(saved);
}
代码示例来源:origin: hantsy/spring-reactive-sample
public PostRepository() {
Stream.of("post one", "post two").forEach(title -> {
Long id = this.nextId();
data.put(id, Post.builder().id(id).title(title).content("content of " + title).build());
});
}
内容来源于网络,如有侵权,请联系作者删除!