Add tag module with post associations

This commit is contained in:
Tim
2025-07-02 13:19:55 +08:00
parent 3449310a19
commit f50201aef6
13 changed files with 249 additions and 9 deletions

View File

@@ -69,8 +69,13 @@ class ComplexFlowIntegrationTest {
Map.of("name", "general"), adminToken);
Long catId = ((Number)catResp.getBody().get("id")).longValue();
ResponseEntity<Map> tagResp = postJson("/api/tags",
Map.of("name", "java"), adminToken);
Long tagId = ((Number)tagResp.getBody().get("id")).longValue();
ResponseEntity<Map> postResp = postJson("/api/posts",
Map.of("title", "Hello", "content", "World", "categoryId", catId), t1);
Map.of("title", "Hello", "content", "World", "categoryId", catId,
"tagIds", List.of(tagId)), t1);
Long postId = ((Number)postResp.getBody().get("id")).longValue();
ResponseEntity<Map> c1Resp = postJson("/api/posts/" + postId + "/comments",
@@ -122,8 +127,13 @@ class ComplexFlowIntegrationTest {
catId = ((Number)catResp.getBody().get("id")).longValue();
}
ResponseEntity<Map> tagResp = postJson("/api/tags",
Map.of("name", "spring"), adminToken);
Long tagId = ((Number)tagResp.getBody().get("id")).longValue();
ResponseEntity<Map> postResp = postJson("/api/posts",
Map.of("title", "React", "content", "Test", "categoryId", catId), t1);
Map.of("title", "React", "content", "Test", "categoryId", catId,
"tagIds", List.of(tagId)), t1);
Long postId = ((Number)postResp.getBody().get("id")).longValue();
postJson("/api/posts/" + postId + "/reactions",

View File

@@ -73,8 +73,13 @@ class PublishModeIntegrationTest {
Map.of("name", "review"), adminToken);
Long catId = ((Number)catResp.getBody().get("id")).longValue();
ResponseEntity<Map> tagResp = postJson("/api/tags",
Map.of("name", "t1"), adminToken);
Long tagId = ((Number)tagResp.getBody().get("id")).longValue();
ResponseEntity<Map> postResp = postJson("/api/posts",
Map.of("title", "Need", "content", "Review", "categoryId", catId), userToken);
Map.of("title", "Need", "content", "Review", "categoryId", catId,
"tagIds", List.of(tagId)), userToken);
Long postId = ((Number)postResp.getBody().get("id")).longValue();
List<?> list = rest.getForObject("/api/posts", List.class);

View File

@@ -63,8 +63,12 @@ class SearchIntegrationTest {
ResponseEntity<Map> catResp = postJson("/api/categories", Map.of("name", "misc"), admin);
Long catId = ((Number)catResp.getBody().get("id")).longValue();
ResponseEntity<Map> tagResp = postJson("/api/tags", Map.of("name", "misc"), admin);
Long tagId = ((Number)tagResp.getBody().get("id")).longValue();
ResponseEntity<Map> postResp = postJson("/api/posts",
Map.of("title", "Hello World Nice", "content", "Some content", "categoryId", catId), user);
Map.of("title", "Hello World Nice", "content", "Some content", "categoryId", catId,
"tagIds", List.of(tagId)), user);
Long postId = ((Number)postResp.getBody().get("id")).longValue();
postJson("/api/posts/" + postId + "/comments",