1use serde::Serialize;
2use serde::Deserialize;
3
4#[derive(Debug, Serialize, Deserialize)]
5pub struct UserModule {
6 pub id: i64,
7 pub code: String,
8 pub year: i32,
9 pub description: String,
10 pub credits: i32,
11 pub role: String,
12 pub created_at: String,
13 pub updated_at: String,
14}
15
16#[derive(Debug, Serialize, Deserialize)]
17pub struct UserResponse {
18 pub id: i64,
19 pub username: String,
20 pub email: String,
21 pub admin: bool,
22 pub created_at: String,
23 pub updated_at: String,
24}
25
26impl From<db::models::user::Model> for UserResponse {
27 fn from(user: db::models::user::Model) -> Self {
28 Self {
29 id: user.id,
30 username: user.username,
31 email: user.email,
32 admin: user.admin,
33 created_at: user.created_at.to_rfc3339(),
34 updated_at: user.updated_at.to_rfc3339(),
35 }
36 }
37}