feat(export): add user devices export
zhenyi committed
Added lib/export/user/devices.rs lib/export/user/devices.rs +41 −0 View lib/export/user/devices.rs
@@ -0,0 +1,41 @@
1use serde::{Deserialize, Serialize};
2use time::format_description::well_known::Rfc3339;
3use utoipa::ToSchema;
4use uuid::Uuid;
5
6#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
7pub struct DeviceView {
8 pub id: Uuid,
9 pub device_name: Option<String>,
10 pub device_type: Option<String>,
11 pub os: Option<String>,
12 pub user_agent: Option<String>,
13 pub is_trusted: bool,
14 pub first_seen_at: String,
15 pub last_seen_at: String,
16 pub created_at: String,
17 pub updated_at: String,
18}
19
20impl From<db::user::user_devices::Model> for DeviceView {
21 fn from(m: db::user::user_devices::Model) -> Self {
22 Self {
23 id: m.id,
24 device_name: m.device_name,
25 device_type: m.device_type,
26 os: m.os,
27 user_agent: m.user_agent,
28 is_trusted: m.is_trusted,
29 first_seen_at: m.first_seen_at.format(&Rfc3339).unwrap_or_default(),
30 last_seen_at: m.last_seen_at.format(&Rfc3339).unwrap_or_default(),
31 created_at: m.created_at.format(&Rfc3339).unwrap_or_default(),
32 updated_at: m.updated_at.format(&Rfc3339).unwrap_or_default(),
33 }
34 }
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
38pub struct UpdateDeviceCmd {
39 pub device_name: Option<Option<String>>,
40 pub is_trusted: Option<bool>,
41}
No newline at end of file