Skip to content

Commit

Permalink
feat(fkl): add field support
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 25, 2022
1 parent 5e89764 commit 29dbb24
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
25 changes: 22 additions & 3 deletions crates/fkl_parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ValueObject Notifications { }
initializer: None,
type_type: "".to_string(),
},
fields: vec![]
fields: vec![],
},
Entity {
name: "Reservation".to_string(),
Expand All @@ -210,7 +210,19 @@ ValueObject Notifications { }
initializer: None,
type_type: "".to_string(),
},
fields: vec![],
fields: vec![
Field { name: "id".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "token".to_string(), initializer: None, type_type: "UUID".to_string() },
Field { name: "status".to_string(), initializer: Some("ReservationStatus.OPEN".to_string()), type_type: "ReservationStatus".to_string() },
Field { name: "expiresAt".to_string(), initializer: None, type_type: "LocalDateTime".to_string() },
Field { name: "createdAt".to_string(), initializer: None, type_type: "LocalDateTime".to_string() },
Field { name: "screeningId".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "screeningStartTime".to_string(), initializer: None, type_type: "LocalDateTime".to_string() },
Field { name: "name".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "surname".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "tickets".to_string(), initializer: None, type_type: "Set<Ticket>".to_string() },
Field { name: "totalPrice".to_string(), initializer: None, type_type: "BigDecimal".to_string() },
],
},
],
}
Expand All @@ -232,7 +244,14 @@ ValueObject Notifications { }
initializer: None,
type_type: "".to_string(),
},
fields: vec![],
fields: vec![
Field { name: "id".to_string(), initializer: None, type_type: "UUID".to_string() },
Field { name: "mobile".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "email".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "username".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "password".to_string(), initializer: None, type_type: "String".to_string() },
Field { name: "address".to_string(), initializer: None, type_type: "String".to_string() },
],
}
],
}
Expand Down
16 changes: 14 additions & 2 deletions crates/fkl_parser/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ impl MirTransform {
})
}

fn update_aggregates(&self) -> Vec<BoundedContext> {
fn update_aggregates(&mut self) -> Vec<BoundedContext> {
let mut contexts = vec![];

self.aggregates.clone().iter().for_each(|(name, aggregate)| {
aggregate.entities.iter().for_each(|entity| {
if let Some(exist_entity) = self.entities.get(&entity.name) {
let aggregate = self.aggregates.get_mut(name).unwrap();
aggregate.entities.remove(aggregate.entities.iter().position(|e| e.name == entity.name).unwrap());
aggregate.entities.push(exist_entity.clone());
}
});
});

self.contexts.values().for_each(|origin| {
let mut context: BoundedContext = BoundedContext::new(&origin.name);

Expand Down Expand Up @@ -267,7 +277,9 @@ Entity Shopping {
initializer: None,
type_type: "".to_string(),
},
fields: vec![],
fields: vec![
Field { name: "id".to_string(), initializer: None, type_type: "String".to_string() }
],
}
],
}],
Expand Down

0 comments on commit 29dbb24

Please sign in to comment.