mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-14 08:00:45 +08:00
feat: do my test
This commit is contained in:
@@ -5,8 +5,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
✅
|
||||||
curl http://localhost:8080/api/admin/hello \
|
curl http://localhost:8080/api/admin/hello \
|
||||||
-H "Authorization: Bearer <token>"
|
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0X3VzZXIxIiwiaWF0IjoxNzUxMjg0OTU2LCJleHAiOjE3NTEzNzEzNTZ9.u84elcDTK2gIvuS4dKJCdE21pRSgY265fvdm9m9DnCQ"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -12,25 +12,26 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
✅
|
||||||
curl -X POST http://localhost:8080/api/auth/register \
|
curl -X POST http://localhost:8080/api/auth/register \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"username": "test_user",
|
"username": "test_user1",
|
||||||
"email": "cjt807916@gmail.com",
|
"email": "1216414009@qq.com",
|
||||||
"password": "password"
|
"password": "password"
|
||||||
}'
|
}'
|
||||||
|
✅
|
||||||
curl -X POST http://localhost:8080/api/auth/verify \
|
curl -X POST http://localhost:8080/api/auth/verify \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"username": "test_user",
|
"username": "test_user1",
|
||||||
"code": "361332"
|
"code": "451247"
|
||||||
}'
|
}'
|
||||||
|
✅
|
||||||
curl -X POST http://localhost:8080/api/auth/login \
|
curl -X POST http://localhost:8080/api/auth/login \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"username": "test_user",
|
"username": "test_user1",
|
||||||
"password": "password"
|
"password": "password"
|
||||||
}'
|
}'
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ import java.util.stream.Collectors;
|
|||||||
/*
|
/*
|
||||||
curl -X POST http://localhost:8080/api/posts \
|
curl -X POST http://localhost:8080/api/posts \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: Bearer <token>" \
|
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0X3VzZXIxIiwiaWF0IjoxNzUxMjg0OTU2LCJleHAiOjE3NTEzNzEzNTZ9.u84elcDTK2gIvuS4dKJCdE21pRSgY265fvdm9m9DnCQ" \
|
||||||
-d '{ "title": "First", "content": "Post" }'
|
-d '{ "title": "First", "content": "Post" }'
|
||||||
|
|
||||||
curl http://localhost:8080/api/posts \
|
curl http://localhost:8080/api/posts \
|
||||||
-H "Authorization: Bearer <token>"
|
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0X3VzZXIxIiwiaWF0IjoxNzUxMjg0OTU2LCJleHAiOjE3NTEzNzEzNTZ9.u84elcDTK2gIvuS4dKJCdE21pRSgY265fvdm9m9DnCQ"
|
||||||
|
|
||||||
curl http://localhost:8080/api/posts/1 \
|
curl http://localhost:8080/api/posts/1 \
|
||||||
-H "Authorization: Bearer <token>"
|
-H "Authorization: Bearer <token>"
|
||||||
@@ -48,6 +48,7 @@ public class PostController {
|
|||||||
return postService.listPosts().stream().map(this::toDto).collect(Collectors.toList());
|
return postService.listPosts().stream().map(this::toDto).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo(tim): 希望返回文章所有评论,包含所有评论的子评论(包含reaction)、文章本身的reaction
|
||||||
private PostDto toDto(Post post) {
|
private PostDto toDto(Post post) {
|
||||||
PostDto dto = new PostDto();
|
PostDto dto = new PostDto();
|
||||||
dto.setId(post.getId());
|
dto.setId(post.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user