mirror of
https://github.com/halo-dev/plugin-starter.git
synced 2025-10-13 22:56:50 +00:00
feat: add reverse proxy config
This commit is contained in:
@@ -33,6 +33,9 @@ dependencies {
|
||||
compileOnly 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
annotationProcessor 'io.github.guqing:pluggable-suite:0.0.1-SNAPSHOT'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package io.github.guqing.apples;
|
||||
package io.github.guqing.template;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
27
src/main/java/io/github/guqing/template/post/Post.java
Normal file
27
src/main/java/io/github/guqing/template/post/Post.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package io.github.guqing.template.post;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author guqing
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Data
|
||||
public class Post {
|
||||
private String id;
|
||||
private String userId;
|
||||
private String topicId;
|
||||
private String raw;
|
||||
private String cooked;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime deletedAt;
|
||||
private String replyToPostNumber;
|
||||
private Integer replyCount;
|
||||
private Integer quoteCount;
|
||||
private Integer likeCount;
|
||||
private Integer offTopicCount;
|
||||
private Integer postType;
|
||||
private Integer sortOrder;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package io.github.guqing.template.post;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* @author guqing
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/apis/template.guqing.github.com/v1alpha1/posts")
|
||||
public class PostController {
|
||||
|
||||
private final PostService postService;
|
||||
|
||||
public PostController(PostService postService) {
|
||||
this.postService = postService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Flux<Post> list() {
|
||||
return postService.list();
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package io.github.guqing.template.post;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* @author guqing
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Component
|
||||
public class PostRepository {
|
||||
|
||||
private final Map<String, Post> postMap = new ConcurrentHashMap<>();
|
||||
|
||||
public PostRepository() {
|
||||
Post post = new Post();
|
||||
post.setId(UUID.randomUUID().toString());
|
||||
post.setRaw("静态方法适合生成简单的序列,当需要复杂的逻辑时,则应该使用 generate() 或 create() 方法。\n");
|
||||
post.setCooked(post.getRaw());
|
||||
post.setPostType(1);
|
||||
post.setCreatedAt(LocalDateTime.now());
|
||||
post.setLikeCount(1);
|
||||
post.setReplyCount(0);
|
||||
post.setOffTopicCount(0);
|
||||
post.setUserId(UUID.randomUUID().toString());
|
||||
post.setTopicId(UUID.randomUUID().toString());
|
||||
post.setSortOrder(1);
|
||||
postMap.put(post.getId(), post);
|
||||
}
|
||||
|
||||
public Flux<Post> findAll() {
|
||||
return Flux.create(sink -> {
|
||||
for (Post value : postMap.values()) {
|
||||
sink.next(value);
|
||||
}
|
||||
sink.complete();
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package io.github.guqing.template.post;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
/**
|
||||
* @author guqing
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Service
|
||||
public class PostService {
|
||||
|
||||
@Autowired
|
||||
private PostRepository postRepository;
|
||||
|
||||
public Flux<Post> list() {
|
||||
return postRepository.findAll();
|
||||
}
|
||||
}
|
8
src/main/resources/extensions/reverseproxy.yaml
Normal file
8
src/main/resources/extensions/reverseproxy.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: ReverseProxy
|
||||
metadata:
|
||||
name: reverse-proxy-template
|
||||
rules:
|
||||
- path: /assets/io.github.guqing.template/**
|
||||
file:
|
||||
directory: static
|
@@ -14,4 +14,4 @@ spec:
|
||||
# 'displayName' explains what the plugin does in only a few words
|
||||
displayName: "测试插件"
|
||||
description: "这是一个用来测试的插件"
|
||||
license: MIT
|
||||
license: MIT1
|
||||
|
BIN
src/main/resources/static/image.jpeg
Normal file
BIN
src/main/resources/static/image.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 345 KiB |
1
src/main/resources/static/some.txt
Normal file
1
src/main/resources/static/some.txt
Normal file
@@ -0,0 +1 @@
|
||||
花径不曾缘客扫,蓬门今始为君开
|
1
src/main/resources/static/test.html
Normal file
1
src/main/resources/static/test.html
Normal file
@@ -0,0 +1 @@
|
||||
<div>测试中文乱码 hello apples</div>
|
Reference in New Issue
Block a user