-
Notifications
You must be signed in to change notification settings - Fork 0
/
curl.txt
133 lines (120 loc) · 29.6 KB
/
curl.txt
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}' localhost:8080/users
curl -i -H 'Content-Type:application/json' localhost:8080/users
curl -i -H 'Content-Type:application/json' localhost:8080/users/5ea00161-dd91-479c-614d-a80dd55732e4
Please output Swagger in yaml format that meets the following conditions
POST /api/users 要求:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"} 返答:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
GET /api/users 返答:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
GET /api/users/:id 要求:idはuuid.UUID 返答:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
POST /api/texts 要求:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2} 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
GET /api/texts 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2},{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2},{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
GET /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
PUT /api/texts 要求:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2} 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
DELETE /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
POST /api/tags 要求:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"} 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
GET /api/tags 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
GET /api/tags/:id 要求:idはuuid.UUID 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
POST /api/like 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like/user/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like/text/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
PUT /api/like/:id 要求:idはuuid.UUID 返答:なし
DELETE /api/like/user/:id 要求:idはuuid.UUID 返答:なし
DELETE /api/like/text/:id 要求:idはuuid.UUID 返答:なし
POST /api/like/delete 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:なし
POST /api/create 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create/user/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create/text/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
PUT /api/create/:id 要求:idはuuid.UUID 返答:なし
DELETE /api/create/user/:id 要求:idはuuid.UUID 返答:なし
DELETE /api/create/text/:id 要求:idはuuid.UUID 返答:なし
POST /api/create/delete 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:なし
仕様:文章を投稿するアプリケーション
UserはログインするとUUIDが生成され、それをキャッシュに保存する。
ログアウトを押すと、保存されているキャッシュを消去する。
Userは文章を投稿する際に、キャッシュされたUUIDをuser_idとして含める。
キャッシュされたUUIDがないときは、ログインをしてくださいと表示させる。
文章を投稿するときにtagをつけられるようにする。
投稿後にサーバー側から帰ってきたJSONの`text_id`をUserと紐付ける。
ほかのUserが投稿した長文にいいねとイマイチをおすことができる。
投稿にはtagをつけることができ、似たような文章が探しやすい。
検索機能では、tagから文章を探すことができる。
ログインしている場合、いいねをおすことができる。もし作ったひとのuser_idとブラウザキャッシュのuser_idが一致すれば、編集と削除をすることができる。
バックエンドの仕様:
1 すべてのUserの取得 GET /api/users 返答:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
5 特定のidのUserの取得 GET /api/users/:id 要求:idはuuid.UUID 返答:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
2 文章の投稿 POST /api/texts 要求:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2} 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
3 文章の一覧の取得 GET /api/texts 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2},{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2},{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
4 特定の文章の取得 GET /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
4 文章の変更 PUT /api/texts 要求:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2} 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
4 文章の削除 DELETE /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
2 文章にタグの追加 POST /api/tag 要求:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"} 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
3 タグの一覧の取得 GET /api/tag 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
4 特定の文章についているタグの取得 GET /api/tag/text/:id 要求:idはuuid.UUID 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
3 特定のタグがついている文章の取得 GET /api/tag/tag/:id 要求:idはuuid.UUID 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
4 いいねを押す POST /api/like 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
//////// GET /api/like 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
5 特定のUserがいいねを押したすべての投稿を取得 GET /api/like/user/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
特定の文章にいいねを押したユーザーの一覧の取得 GET /api/like/text/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
//////// PUT /api/like/:id 要求:idはuuid.UUID 返答:なし
特定のUserが押したいいねの全削除 DELETE /api/like/user/:id 要求:idはuuid.UUID 返答:なし
特定の文章に押されたいいねの全削除 DELETE /api/like/text/:id 要求:idはuuid.UUID 返答:なし
特定の文章に特定のUserが押したいいねの削除 POST /api/like/delete 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:なし
2 Userと文章を紐付ける POST /api/create 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
//////// GET /api/create 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
5 特定のUserが作った文章の一覧の取得 GET /api/create/user/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
//////// GET /api/create/text/:id 要求:idはuuid.UUID 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
//////// PUT /api/create/:id 要求:idはuuid.UUID 返答:なし
//////// DELETE /api/create/user/:id 要求:idはuuid.UUID 返答:なし
//////// DELETE /api/create/text/:id 要求:idはuuid.UUID 返答:なし
特定のUserの文章の全削除 POST /api/create/delete 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:なし
返答には、StatusCodeは必ず帰ってくる。
Write a front end for a web application that meets the specifications below, using React. No explanation is necessary.
Specification: An application for posting text.
When a User logs in, a UUID is generated and stored in the cache.
When the User posts a sentence, the cached UUID is included as user_id.
If the cached UUID is not available, the user is prompted to log in.
Pressing logout clears the stored cache.
You can like and tag long posts made by other users.
Posts can be tagged, making it easy to find similar sentences.
A search function allows users to search for sentences by tag.
The backend specification is made as follows.
Backend specification: POST /api/users Request: {"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z "} Reply: {"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
GET /api/users Reply:{"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id ": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"},{"user_id": "5ea00161-dd91-479c -614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43:20.844Z"}
GET /api/users/:id Request: id is uuid.UUID Reply: {"user_id": "5ea00161-dd91-479c-614d-a80dd55732e4", "name": "testtest", "created_at": "2023-03-18T02:43: 20.844Z"}
POST /api/texts request: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03-21T10:00:00Z", "changed_ at": "2022-03-21T11:30:00Z", "good_count": "10, "bad_count": "2} Reply: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430 c8", "created_at": "2022-03-21T10:00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2}
GET /api/texts Reply: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03-21T10:00:00Z", "changed_ at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2},{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title ", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","" created_at": "2022-03-21T10:00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2},{"text_id": "6ba7b810-9dad-11 d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_ id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03-21T10:00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10 , "bad_count": 2}
GET /api/texts/:id Request: id is uuid.UUID Reply: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03-21T10: 00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2}
PUT /api/texts request: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03-21T10:00:00Z", "changed_ at": "2022-03-21T11:30:00Z", "good_count": "10, "bad_count": "2} Reply: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430 c8", "created_at": "2022-03-21T10:00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2}
DELETE /api/texts/:id request: id is uuid.UUID reply: {"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "title": "Example Title", "content": "This is an example content for the Text struct", "user_name": "example_user", "user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "created_at": "2022-03- 21T10:00:00Z", "changed_at": "2022-03-21T11:30:00Z", "good_count": 10, "bad_count": 2}
POST /api/tags Request: {"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "tag_name": "example_tag"} Reply: {"tag_id": "6ba7b810-9dad-11d1-80b4-00c04 fd430c8", "tag_name": "example_tag"}
GET /api/tags Reply: {"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd 430c8", "tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "tag_name": "example_tag"}
GET /api/tags/:id Request: id is uuid.UUID Reply: {"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "tag_name": "example_tag"}
POST /api/like Request: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} Reply: {"user_id": "4d4b 711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like Reply: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711 c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f ", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like/user/:id request:id is uuid.UUID reply:{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b 60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1ab4 -4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/like/text/:id request:id is uuid.UUID reply:{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b 60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1ab4 -4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
PUT /api/like/:id request: id is uuid.UUID reply: none
DELETE /api/like/user/:id request: id is uuid.UUID reply: none
DELETE /api/like/text/:id request: id is uuid.UUID Reply: none
POST /api/like/delete request: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} No reply
POST /api/create Request: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} Reply: {"user_id": "4d 4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create Reply: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b 711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b 5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create/user/:id Request: id is uuid.UUID Reply: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e 5b60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1 ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
GET /api/create/text/:id Request: id is uuid.UUID Reply: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e 5b60"},{"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"},{"user_id": "4d4b711c-1 ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}
PUT /api/create/:id request: id is uuid.UUID reply: none
DELETE /api/create/user/:id request: id is uuid.UUID reply: none
DELETE /api/create/text/:id request: id is uuid.UUID Reply: none
POST /api/create/delete request: {"user_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f", "text_id": "4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} Reply: no
StatusCode is always returned in the reply.
仕様:文章を投稿するアプリケーション
URIは`/text/:text_id`
文章の詳細が見られる。タイトルと文章と作ったUserの名前と作った日時といいねの数が表示される。
ログインしている場合、いいねをおすことができる。もし作ったUserの`user_id`とブラウザキャッシュの`user_id`が一致すれば、編集と削除をすることができる。
バックエンドの仕様は以下のように作られている。
バックエンドの仕様:
特定の文章の取得 GET /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
文章の変更 PUT /api/texts 要求:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2} 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
文章の削除 DELETE /api/texts/:id 要求:idはuuid.UUID 返答:{"text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","title": "Example Title","content": "This is an example content for the Text struct","user_name": "example_user","user_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","created_at": "2022-03-21T10:00:00Z","changed_at": "2022-03-21T11:30:00Z","good_count": 10,"bad_count": 2}
特定の文章についているタグの取得 GET /api/tag/text/:id 要求:idはuuid.UUID 返答:{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"},{"tag_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","text_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8","tag_name": "example_tag"}
いいねを押す POST /api/like 要求:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"} 返答:{"user_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b5f","text_id":"4d4b711c-1ab4-4ad4-a828-5d1a5b5e5b60"}