Skip to content

Commit 1e671d5

Browse files
authored
feat(articles): list public articles, vote, comment (#36)
1 parent c3338d5 commit 1e671d5

File tree

2 files changed

+64
-6
lines changed

2 files changed

+64
-6
lines changed

articles.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
## 列出文章
44

5+
<table>
6+
<tr>
7+
<th align="right">请求</th>
8+
<td><code>GET /article</code></td>
9+
</tr>
10+
<tr>
11+
<th align="right">参数</th>
12+
<td><code>{ category?: number; page?: number }</code></td>
13+
</tr>
14+
<tr>
15+
<th align="right">响应主体</th>
16+
<td><code>application/json</code> (<code>LentilleDataResponse&lt;ArticleListData&gt;</code>)</td>
17+
</tr>
18+
</table>
19+
20+
## 列出用户文章
21+
522
<table>
623
<tr>
724
<th align="right">请求</th>
@@ -17,7 +34,7 @@
1734
</tr>
1835
</table>
1936

20-
## 列出发布的文章
37+
## 列出创建的文章
2138

2239
<table>
2340
<tr>
@@ -30,7 +47,7 @@
3047
</tr>
3148
<tr>
3249
<th align="right">响应主体</th>
33-
<td><code>application/json</code> (<code>LentilleDataResponse&lt;ArticleListData&gt;</code>)</td>
50+
<td><code>application/json</code> (<code>LentilleDataResponse&lt;CreatedArticleListData&gt;</code>)</td>
3451
</tr>
3552
</table>
3653

@@ -177,6 +194,23 @@
177194
</tr>
178195
</table>
179196

197+
## 赞/踩文章
198+
199+
<table>
200+
<tr>
201+
<th align="right">请求</th>
202+
<td><code>POST /api/article/vote/:lid</code></td>
203+
</tr>
204+
<tr>
205+
<th align="right">参数</th>
206+
<td><code>{ vote: number }</code></td>
207+
</tr>
208+
<tr>
209+
<th align="right">响应主体</th>
210+
<td><code>application/json</code> (<code>{ voted: number; upvotes: number }</code>)</td>
211+
</tr>
212+
</table>
213+
180214
## 申请全站推荐
181215

182216
<table>
@@ -220,6 +254,23 @@
220254
</tr>
221255
</table>
222256

257+
## 发表评论
258+
259+
<table>
260+
<tr>
261+
<th align="right">请求</th>
262+
<td><code>POST /article/:lid/reply</code></td>
263+
</tr>
264+
<tr>
265+
<th align="right">请求主体</th>
266+
<td><code>application/json</code> (<code>{ content: string }</code>)</td>
267+
</tr>
268+
<tr>
269+
<th align="right">响应主体</th>
270+
<td><code>application/json</code> (<code>{ reply: Comment }</code>)</td>
271+
</tr>
272+
</table>
273+
223274
## 删除评论
224275

225276
<table>

luogu-api.d.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@ export interface ImageListData {
516516
}
517517

518518
export interface ArticleListData {
519+
articles: List<Article>;
520+
featuredCollections: ArticleCollectionSummary[];
521+
category: number | null;
522+
}
523+
524+
export interface CreatedArticleListData {
519525
articles: List<Article>;
520526
stat: { promoted: number; public: number; hidden: number };
521527
}
@@ -530,6 +536,7 @@ export interface ArticleData {
530536

531537
export interface ArticleCollectionData {
532538
articles: List<Article>;
539+
featuredCollections: ArticleCollectionSummary[];
533540
collection: ArticleCollection;
534541
}
535542

@@ -651,7 +658,7 @@ export interface ProblemSummary {
651658
pid: string;
652659
type: string;
653660
title: string;
654-
difficulty: number;
661+
difficulty: number | null;
655662
}
656663

657664
export interface Problem extends LegacyProblemSummary {
@@ -1103,7 +1110,6 @@ export interface Article {
11031110
}
11041111

11051112
export interface ArticleDetails extends Article {
1106-
id: number;
11071113
contentFull: boolean;
11081114
adminNote: string | null;
11091115
voted?: number | null;
@@ -1118,6 +1124,7 @@ export interface ArticleCollectionSummary {
11181124

11191125
export interface ArticleCollection extends ArticleCollectionSummary {
11201126
opening: boolean;
1127+
featured: number;
11211128
categoryLimitation: null;
11221129
}
11231130

@@ -1140,10 +1147,10 @@ export interface Blog extends BlogSummary {
11401147
}
11411148

11421149
export interface Comment {
1143-
content: string;
11441150
id: number;
1145-
author: UserSummary;
1151+
author: UserSummary & Maybe<SelfSummary>;
11461152
time: number;
1153+
content: string;
11471154
}
11481155

11491156
export interface PageTree {

0 commit comments

Comments
 (0)