Skip to content

Commit d36f5a0

Browse files
committed
fix(users,misc): update user and ranking apis
Closes #46.
1 parent dbc1ede commit d36f5a0

File tree

4 files changed

+193
-64
lines changed

4 files changed

+193
-64
lines changed

luogu-api.d.ts

Lines changed: 119 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export interface DataResponse<T> {
180180
currentTitle: string;
181181
currentTheme: Theme | null;
182182
currentTime: number;
183-
currentUser?: User & Maybe<Self>;
183+
currentUser?: LegacyUser & Maybe<LegacySelf>;
184184
}
185185

186186
export interface LentilleDataResponse<T> {
@@ -189,7 +189,7 @@ export interface LentilleDataResponse<T> {
189189
status: number;
190190
locale: string;
191191
data: T;
192-
user: (UserSummary & Maybe<SelfSummary>) | null;
192+
user: (User & Maybe<Self & SelfStats>) | null;
193193
time: number;
194194
theme: Theme | null;
195195
}
@@ -349,7 +349,7 @@ export interface ConfigResponse {
349349
ContestMethod: {
350350
[id: number]: { type: string; id: number; name: string; color: string };
351351
};
352-
ContestPublicType: {
352+
ContestVisibility: {
353353
type: string;
354354
id: number;
355355
name: string;
@@ -368,14 +368,7 @@ export interface ConfigResponse {
368368
}[];
369369
ProblemFlag: { [id: number]: { type: string; id: number; name: string } };
370370
ProblemType: {
371-
[id: string]: {
372-
type: string;
373-
id: string;
374-
name: string;
375-
vjudge: boolean;
376-
userCreatable: boolean;
377-
searchable: boolean;
378-
};
371+
[id: string]: { type: string; id: string; name: string; tds: string };
379372
};
380373
CodeLanguage: {
381374
[id: number]: {
@@ -409,6 +402,18 @@ export interface ConfigResponse {
409402
TicketStatus: {
410403
[id: number]: { type: string; id: number; name: string; color: string };
411404
};
405+
TrainingType: {
406+
[id: number]: {
407+
type: string;
408+
id: number;
409+
name: string;
410+
public: boolean;
411+
color: string;
412+
scope: "global" | "team" | "user" | "hidden";
413+
select: boolean;
414+
userCreatable: boolean;
415+
};
416+
};
412417
UserMessageReceiveMode: { type: string; id: number; name: string }[];
413418
UserNotificationType: {
414419
[id: number]: { type: string; id: number; name: string };
@@ -440,11 +445,13 @@ export interface ProblemData {
440445
bookmarked: boolean;
441446
contest: ContestSummary | null;
442447
vjudgeUsername: string | null;
443-
lastLanguage: number | null;
444-
lastCode: string | null;
448+
lastLanguage: number;
449+
lastCode: string;
450+
lastCodeAt: number | null;
445451
recommendations: (ProblemSummary & Maybe<ProblemStatus>)[];
446452
forum: Forum | null;
447453
discussions: PostSummary[] | null;
454+
locale: string;
448455
canEdit: boolean;
449456
}
450457

@@ -508,29 +515,57 @@ export interface PostData {
508515
}
509516

510517
export interface UserData {
518+
prizes: []; // TODO
519+
gu: GuRating;
520+
elo: (EloRating & { previous: EloRating | null })[];
521+
dailyCounts: Record<string, [number, number]>;
511522
user: UserDetails & UserStats & Maybe<SelfDetails>;
512-
eloMax: { rating: number; time: number; latest: boolean } | null;
513-
passedProblems?: ProblemSummary[];
514-
submittedProblems?: ProblemSummary[];
515-
teams?: {
516-
team: TeamSummary;
517-
group: Group;
518-
user: UserSummary;
523+
}
524+
525+
export interface UserPracticeData {
526+
passed: ProblemSummary[];
527+
submitted: ProblemSummary[];
528+
elo: EloRating[];
529+
user: UserDetails & UserStats & Maybe<SelfDetails>;
530+
}
531+
532+
export interface UserTeamsData {
533+
teams: {
534+
user: UserSummary & Maybe<SelfSummary>;
519535
type: number;
520-
permission: number;
536+
team: TeamSummary;
537+
pinned: boolean;
521538
}[];
539+
user: UserDetails & UserStats & Maybe<SelfDetails>;
522540
}
523541

524-
export interface UserSettingsData {
525-
userSetting: UserSettings;
526-
usernameUpdateTime: number;
542+
export interface UserAccountsData {
543+
qqGroupToken: string;
544+
vjudgeAccounts: { username: string; oj: string }[];
545+
openidAccounts: { username: string; platform: number }[];
546+
}
547+
548+
export interface UserPreferencesData {
527549
openSourceJoinTime: number;
528-
hasSet2FA: boolean;
529-
ccfLevelShowLevel: number;
530-
vjudgeAccounts: { oj: string; username: string }[];
531-
openIdAccounts: { platform: number; username: string }[];
550+
setting: UserPreferences;
551+
}
552+
553+
export interface UserPrizeSettingsData {
554+
prizeLevel: {
555+
oi: { level: number; show: boolean };
556+
xcpc: { level: number; show: boolean };
557+
};
532558
prizes: []; // TODO
533-
user: UserDetails & Maybe<SelfDetails>;
559+
hasRealName: boolean;
560+
}
561+
562+
export interface UserSecuritySettingsData {
563+
totpSet: boolean;
564+
realName: string | null;
565+
phone: string | null;
566+
email: string | null;
567+
usernameUpdateTime: number;
568+
adminLogs: []; // TODO
534569
}
535570

536571
export interface TeamData {
@@ -721,22 +756,25 @@ export interface ProblemDetails extends Problem {
721756
acceptLanguages: number[];
722757
samples: [input: string, output: string][];
723758
limits: { time: number[]; memory: number[] };
724-
stdCode: string;
725759
showScore?: boolean;
726760
score?: number | null;
761+
bestRecord: {
762+
id: number;
763+
status: number;
764+
enableO2: boolean;
765+
score?: number;
766+
} | null;
727767
vjudge?: { id: string; link: string };
728768
translation: string;
729769
}
730770

731771
export interface ProblemContents {
732-
user: null;
733-
version: 1;
734772
name: string;
735-
background: string;
773+
background: string | null;
736774
description: string;
737-
formatI: string;
738-
formatO: string;
739-
hint: string;
775+
formatI: string | null;
776+
formatO: string | null;
777+
hint: string | null;
740778
locale: string;
741779
}
742780

@@ -971,15 +1009,19 @@ export interface SelfSummary {
9711009
verified: boolean;
9721010
}
9731011

974-
export interface Self extends SelfSummary {
975-
unreadMessageCount: number;
976-
unreadNoticeCount: number;
977-
}
1012+
export interface Self extends SelfSummary {}
9781013

9791014
export interface SelfDetails extends Self {
9801015
organization: null; // TODO
981-
email: string;
982-
phone: string;
1016+
email: string | null;
1017+
phone: string | null;
1018+
realName: string | null;
1019+
}
1020+
1021+
export interface SelfStats {
1022+
unreadMessageCount: number;
1023+
unreadNoticeCount: number;
1024+
learnMode: boolean;
9831025
}
9841026

9851027
export type UserColor =
@@ -1011,11 +1053,10 @@ export interface User extends UserSummary {
10111053
followerCount: number;
10121054
ranking: number | null;
10131055
eloValue: number | null;
1014-
blogAddress: string | null;
10151056
}
10161057

10171058
export interface UserDetails extends User {
1018-
rating?: Rating;
1059+
rating: null;
10191060
registerTime: number;
10201061
introduction: string | null;
10211062
prize: { year: number; contestName: string; prize: string }[];
@@ -1034,8 +1075,11 @@ export interface UserPractice {
10341075
submittedProblemCount: number | null;
10351076
}
10361077

1037-
export interface UserSettings {
1078+
export interface UserPreferences {
1079+
codeFont: string | null;
1080+
colorScheme: null;
10381081
openSource: number;
1082+
codeSharingWithAi: boolean;
10391083
learningMode: boolean;
10401084
messageMode: number;
10411085
acceptPromotion: boolean;
@@ -1138,27 +1182,36 @@ export interface Paste {
11381182
public: boolean;
11391183
}
11401184

1141-
export interface Rating {
1142-
contestRating: number;
1143-
socialRating: number;
1144-
practiceRating: number;
1145-
basicRating: number;
1146-
prizeRating: number;
1147-
calculateTime: number;
1148-
user: UserSummary;
1185+
export interface GuRating {
11491186
rating: number;
1187+
time: number;
1188+
scores: {
1189+
rating: number;
1190+
social: number;
1191+
basic: number;
1192+
contest: number;
1193+
practice: number;
1194+
prize: number;
1195+
};
1196+
}
1197+
1198+
export interface GuRatingDetails extends GuRating {
1199+
user: UserSummary;
11501200
}
11511201

11521202
export interface EloRatingSummary {
1153-
contest: ContestSummary;
11541203
rating: number;
11551204
time: number;
11561205
latest: boolean;
1206+
contest?: ContestSummary;
11571207
}
11581208

11591209
export interface EloRating extends EloRatingSummary {
11601210
userCount: number;
1161-
prevDiff: number;
1211+
prevDiff: number | null;
1212+
}
1213+
1214+
export interface EloRatingDetails extends EloRating {
11621215
user: UserSummary;
11631216
}
11641217

@@ -1309,6 +1362,17 @@ export interface LegacyForum {
13091362
slug: string;
13101363
}
13111364

1365+
/** @deprecated */
1366+
export interface LegacyUser extends User {
1367+
blogAddress: string | null;
1368+
}
1369+
1370+
/** @deprecated */
1371+
export interface LegacySelf extends Self {
1372+
unreadMessageCount: number;
1373+
unreadNoticeCount: number;
1374+
}
1375+
13121376
/** @deprecated */
13131377
export interface LegacyBlog {
13141378
BlogID: number;

misc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</tr>
5353
<tr>
5454
<th align="right">响应主体</th>
55-
<td><code>application/json</code> (<code>DataResponse&lt;{ rankList: List&lt;Rating&gt; }&gt;</code>)</td>
55+
<td><code>application/json</code> (<code>LentilleDataResponse&lt;{ ranking: List&lt;GuRatingDetails&gt; }&gt;</code>)</td>
5656
</tr>
5757
</table>
5858

@@ -69,7 +69,7 @@
6969
</tr>
7070
<tr>
7171
<th align="right">响应主体</th>
72-
<td><code>application/json</code> (<code>DataResponse&lt;{ ranking: List&lt;EloRating &amp; { previous: EloRating | null }&gt; }&gt;</code>)</td>
72+
<td><code>application/json</code> (<code>LentilleDataResponse&lt;{ ranking: List&lt;EloRatingDetails &amp; { previous: EloRatingDetails | null }&gt; }&gt;</code>)</td>
7373
</tr>
7474
</table>
7575

teams.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
</tr>
1414
</table>
1515

16+
## 列出加入的团队
17+
18+
<table>
19+
<tr>
20+
<th align="right">请求</th>
21+
<td><code>GET /user/mine/team</code></td>
22+
</tr>
23+
<tr>
24+
<th align="right">响应主体</th>
25+
<td><code>application/json</code> (<code>LentilleDataResponse&lt;UserTeamsData&gt;</code>)</td>
26+
</tr>
27+
</table>
28+
1629
## 列出团队成员
1730

1831
<table>

0 commit comments

Comments
 (0)