direct_access/root/
dtos.rs1use common::entities::Root;
4use common::types::EntityId;
5use serde::{Deserialize, Serialize};
6use std::convert::From;
7
8#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
9pub struct RootDto {
10 pub id: EntityId,
11 pub created_at: chrono::DateTime<chrono::Utc>,
12 pub updated_at: chrono::DateTime<chrono::Utc>,
13 pub workspace: Option<EntityId>,
14 pub system: Option<EntityId>,
15}
16
17impl From<RootDto> for Root {
18 fn from(dto: RootDto) -> Self {
19 Root {
20 id: dto.id,
21 created_at: dto.created_at,
22 updated_at: dto.updated_at,
23 workspace: dto.workspace,
24 system: dto.system,
25 }
26 }
27}
28
29impl From<&RootDto> for Root {
30 fn from(dto: &RootDto) -> Self {
31 Root {
32 id: dto.id,
33 created_at: dto.created_at,
34 updated_at: dto.updated_at,
35 workspace: dto.workspace,
36 system: dto.system,
37 }
38 }
39}
40
41impl From<Root> for RootDto {
42 fn from(entity: Root) -> Self {
43 RootDto {
44 id: entity.id,
45 created_at: entity.created_at,
46 updated_at: entity.updated_at,
47 workspace: entity.workspace,
48 system: entity.system,
49 }
50 }
51}
52
53#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
54pub struct CreateRootDto {
55 pub created_at: chrono::DateTime<chrono::Utc>,
56 pub updated_at: chrono::DateTime<chrono::Utc>,
57 pub workspace: Option<EntityId>,
58 pub system: Option<EntityId>,
59}
60
61impl From<CreateRootDto> for Root {
62 fn from(dto: CreateRootDto) -> Self {
63 Root {
64 id: 0,
65 created_at: dto.created_at,
66 updated_at: dto.updated_at,
67 workspace: dto.workspace,
68 system: dto.system,
69 }
70 }
71}
72
73impl From<&CreateRootDto> for Root {
74 fn from(dto: &CreateRootDto) -> Self {
75 Root {
76 id: 0,
77 created_at: dto.created_at,
78 updated_at: dto.updated_at,
79 workspace: dto.workspace,
80 system: dto.system,
81 }
82 }
83}
84
85impl From<Root> for CreateRootDto {
86 fn from(entity: Root) -> Self {
87 CreateRootDto {
88 created_at: entity.created_at,
89 updated_at: entity.updated_at,
90 workspace: entity.workspace,
91 system: entity.system,
92 }
93 }
94}
95#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
96pub struct UpdateRootDto {
97 pub id: EntityId,
98 pub created_at: chrono::DateTime<chrono::Utc>,
99 pub updated_at: chrono::DateTime<chrono::Utc>,
100}
101
102impl From<UpdateRootDto> for Root {
103 fn from(dto: UpdateRootDto) -> Self {
104 Root {
105 id: dto.id,
106 created_at: dto.created_at,
107 updated_at: dto.updated_at,
108 workspace: Default::default(),
109 system: Default::default(),
110 }
111 }
112}
113
114impl From<&UpdateRootDto> for Root {
115 fn from(dto: &UpdateRootDto) -> Self {
116 Root {
117 id: dto.id,
118 created_at: dto.created_at,
119 updated_at: dto.updated_at,
120 workspace: Default::default(),
121 system: Default::default(),
122 }
123 }
124}
125
126impl From<Root> for UpdateRootDto {
127 fn from(entity: Root) -> Self {
128 UpdateRootDto {
129 id: entity.id,
130 created_at: entity.created_at,
131 updated_at: entity.updated_at,
132 }
133 }
134}
135
136impl From<RootDto> for UpdateRootDto {
137 fn from(dto: RootDto) -> Self {
138 UpdateRootDto {
139 id: dto.id,
140 created_at: dto.created_at,
141 updated_at: dto.updated_at,
142 }
143 }
144}
145pub use common::direct_access::root::RootRelationshipField;
146
147#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
148pub struct RootRelationshipDto {
149 pub id: EntityId,
150 pub field: RootRelationshipField,
151 pub right_ids: Vec<EntityId>,
152}