Skip to main content

pickcat_api_collection/dto/
auth.rs

1//! 鉴权与入站考试 DTO。
2
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize)]
6pub struct AvatarFieldInUserFieldInSessionDTO {
7    #[serde(rename = "type")]
8    pub typs: String,
9    pub id: u32,
10    pub url: String,
11}
12
13#[derive(Debug, Serialize, Deserialize)]
14pub struct LevelFieldInUserFieldInSessionDTO {
15    pub current: u32,
16}
17
18#[derive(Debug, Serialize, Deserialize)]
19pub struct UserFieldInSessionDTO {
20    pub id: String,
21    pub username: String,
22    #[serde(rename = "createdAt")]
23    pub created_at: String,
24    pub avatar: AvatarFieldInUserFieldInSessionDTO,
25    pub level: LevelFieldInUserFieldInSessionDTO,
26}
27
28#[derive(Serialize, Deserialize, Debug)]
29pub struct SessionDTO {
30    pub user: UserFieldInSessionDTO,
31    #[serde(rename = "createdAt")]
32    pub created_at: String,
33    #[serde(rename = "expiresAt")]
34    pub expires_at: String,
35}
36
37#[derive(Debug, Serialize, Deserialize)]
38pub struct RegistrationDTO {
39    id: String,
40    status: String,
41    expires_at: String,
42}
43
44#[derive(Debug, Serialize, Deserialize)]
45pub struct SendRegistrationDTO {
46    pub username: String,
47    pub email: String,
48    #[serde(rename = "captchaVerifyParam")]
49    pub captcha_verify_param: String,
50}
51
52#[derive(Debug, Serialize, Deserialize)]
53pub struct SendVerifyEmailDTO {
54    pub code: String,
55    pub password: String,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct AvatarFieldInUserDTO {
60    #[serde(rename = "type")]
61    pub typs: String,
62    pub id: u32,
63    pub url: String,
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67pub struct LevelFieldInUserDTO {
68    pub current: u32,
69}
70
71#[derive(Debug, Serialize, Deserialize)]
72pub struct StatsFieldInUserDTO {
73    pub followers: u32,
74    pub following: u32,
75    pub topics: u32,
76    pub replies: u32,
77}
78
79#[derive(Debug, Serialize, Deserialize)]
80pub struct ViewerStateFieldInUserDTO {
81    pub following: bool,
82    #[serde(rename = "canFollow")]
83    pub can_follow: bool,
84}
85
86#[derive(Debug, Serialize, Deserialize)]
87pub struct VerifyEmailDTO {
88    pub id: String,
89    pub username: String,
90    pub avatar: AvatarFieldInUserDTO,
91    pub bio: Option<String>,
92    pub region: Option<String>,
93    #[serde(rename = "showFollowingList")]
94    pub show_following_list: bool,
95    #[serde(rename = "showFollowersList")]
96    pub show_followers_list: bool,
97    #[serde(rename = "createdAt")]
98    pub created_at: String,
99    pub level: LevelFieldInUserDTO,
100    pub stats: StatsFieldInUserDTO,
101    #[serde(rename = "viewerState")]
102    pub viewer_state: ViewerStateFieldInUserDTO,
103}
104
105#[derive(Debug, Serialize, Deserialize)]
106pub struct ExamStatusResultDTO {
107    #[serde(rename = "attemptId")]
108    pub attempt_id: String,
109    pub status: String,
110    #[serde(rename = "totalQuestions")]
111    pub total_questions: u32,
112    #[serde(rename = "correctCount")]
113    pub correct_count: u32,
114    #[serde(rename = "requiredCorrectCount")]
115    pub required_correct_count: u32,
116    #[serde(rename = "startedAt")]
117    pub started_at: String,
118    #[serde(rename = "finishedAt")]
119    pub finished_at: String,
120}
121
122#[derive(Debug, Serialize, Deserialize)]
123pub struct ExamStatusDTO {
124    pub state: String,
125    pub result: Option<ExamStatusResultDTO>,
126}
127
128#[derive(Debug, Serialize, Deserialize)]
129pub struct StartExamAttemptDTO {
130    #[serde(rename = "attemptId")]
131    pub attempt_id: String,
132    #[serde(rename = "totalQuestions")]
133    pub total_questions: u32,
134    #[serde(rename = "completedQuestions")]
135    pub completed_questions: u32,
136    #[serde(rename = "currentOrdinal")]
137    pub current_ordinal: u32,
138    #[serde(rename = "deadlineAt")]
139    pub deadline_at: String,
140    #[serde(rename = "startedAt")]
141    pub started_at: String,
142}
143
144#[derive(Debug, Serialize, Deserialize)]
145pub struct StartExamDTO {
146    pub state: String,
147    pub attempt: StartExamAttemptDTO,
148}
149
150#[derive(Debug, Serialize, Deserialize)]
151pub struct CurrentQuestionOptionDTO {
152    pub id: String,
153    pub position: u32,
154    #[serde(rename = "contentHtml")]
155    pub content_html: String,
156}
157
158#[derive(Debug, Serialize, Deserialize)]
159pub struct CurrentQuestionDTO {
160    pub state: String,
161    #[serde(rename = "attemptId")]
162    pub attempt_id: String,
163    #[serde(rename = "questionId")]
164    pub question_id: String,
165    pub ordinal: u32,
166    #[serde(rename = "totalQuestions")]
167    pub total_questions: u32,
168    #[serde(rename = "questionType")]
169    pub question_type: String,
170    #[serde(rename = "stemHtml")]
171    pub stem_html: String,
172    pub options: Vec<CurrentQuestionOptionDTO>,
173    #[serde(rename = "deliveryToken")]
174    pub delivery_token: String,
175    #[serde(rename = "deadlineAt")]
176    pub deadline_at: String,
177}
178
179#[derive(Debug, Serialize, Deserialize)]
180pub struct SubmitExamAnswerDTO {
181    #[serde(rename = "questionId")]
182    pub question_id: String,
183    #[serde(rename = "deliveryToken")]
184    pub delivery_token: String,
185    #[serde(rename = "selectedOptionIds")]
186    pub selected_option_ids: Vec<String>,
187}
188
189#[derive(Debug, Serialize, Deserialize)]
190pub struct SendSubmitAnswerDTO {
191    #[serde(rename = "questionId")]
192    pub question_id: String,
193    #[serde(rename = "deliveryToken")]
194    pub delivery_token: String,
195    #[serde(rename = "selectedOptionIds")]
196    pub selected_option_ids: Vec<String>,
197}
198
199#[derive(Debug, Serialize, Deserialize)]
200pub struct SubmitExamAnswerResponseDTO {
201    pub state: String,
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub attempt: Option<StartExamAttemptDTO>,
204    #[serde(skip_serializing_if = "Option::is_none")]
205    pub result: Option<ExamStatusResultDTO>,
206}