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