Merge pull request 'fix: include product_id in Customization aggregate obj' (#50) from cust-obj-prod-id into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: #50
This commit is contained in:
commit
7c416feacd
6 changed files with 8 additions and 58 deletions
|
@ -49,6 +49,7 @@ pub mod tests {
|
||||||
let customization = CustomizationBuilder::default()
|
let customization = CustomizationBuilder::default()
|
||||||
.name("customization_name".into())
|
.name("customization_name".into())
|
||||||
.customization_id(UUID)
|
.customization_id(UUID)
|
||||||
|
.product_id(UUID)
|
||||||
.deleted(false)
|
.deleted(false)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -62,6 +62,7 @@ mod tests {
|
||||||
let customization = {
|
let customization = {
|
||||||
CustomizationBuilder::default()
|
CustomizationBuilder::default()
|
||||||
.name(customization_name.into())
|
.name(customization_name.into())
|
||||||
|
.product_id(UUID)
|
||||||
.customization_id(UUID)
|
.customization_id(UUID)
|
||||||
.deleted(false)
|
.deleted(false)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -35,6 +35,7 @@ impl From<CustomizationView> for Customization {
|
||||||
CustomizationBuilder::default()
|
CustomizationBuilder::default()
|
||||||
.name(v.name)
|
.name(v.name)
|
||||||
.customization_id(v.customization_id)
|
.customization_id(v.customization_id)
|
||||||
|
.product_id(v.product_id)
|
||||||
.deleted(v.deleted)
|
.deleted(v.deleted)
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -49,8 +50,8 @@ impl View<Customization> for CustomizationView {
|
||||||
match &event.payload {
|
match &event.payload {
|
||||||
InventoryEvent::CustomizationAdded(val) => {
|
InventoryEvent::CustomizationAdded(val) => {
|
||||||
self.name = val.customization().name().into();
|
self.name = val.customization().name().into();
|
||||||
self.product_id = val.product_id().clone();
|
self.product_id = *val.customization().product_id();
|
||||||
self.customization_id = val.customization().customization_id().clone();
|
self.customization_id = *val.customization().customization_id();
|
||||||
|
|
||||||
self.deleted = false;
|
self.deleted = false;
|
||||||
}
|
}
|
||||||
|
@ -59,58 +60,6 @@ impl View<Customization> for CustomizationView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InnerCustomization {
|
|
||||||
name: String,
|
|
||||||
customization_id: Uuid,
|
|
||||||
product_id: Uuid,
|
|
||||||
deleted: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<InnerCustomization> for Customization {
|
|
||||||
fn from(value: InnerCustomization) -> Self {
|
|
||||||
CustomizationBuilder::default()
|
|
||||||
.name(value.name)
|
|
||||||
.customization_id(value.customization_id)
|
|
||||||
.deleted(value.deleted)
|
|
||||||
.build()
|
|
||||||
.unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//impl InnerCustomizationView {
|
|
||||||
// async fn get_customizations(
|
|
||||||
// &self,
|
|
||||||
// db: &InventoryDBPostgresAdapter,
|
|
||||||
// ) -> Result<Vec<Customization>, PersistenceError> {
|
|
||||||
// let customizations = if self.customizations_available {
|
|
||||||
// let mut inner_customizations = sqlx::query_as!(
|
|
||||||
// InnerCustomization,
|
|
||||||
// "SELECT
|
|
||||||
// name,
|
|
||||||
// customization_id,
|
|
||||||
// deleted,
|
|
||||||
// customization_id
|
|
||||||
// FROM
|
|
||||||
// cqrs_inventory_product_customizations_query
|
|
||||||
// WHERE
|
|
||||||
// customization_id = $1;",
|
|
||||||
// self.customization_id
|
|
||||||
// )
|
|
||||||
// .fetch_all(&db.pool)
|
|
||||||
// .await
|
|
||||||
// .map_err(PostgresAggregateError::from)?;
|
|
||||||
//
|
|
||||||
// let mut customizations = Vec::with_capacity(inner_customizations.len());
|
|
||||||
// for c in inner_customizations.drain(0..) {
|
|
||||||
// customizations.push(c.into());
|
|
||||||
// }
|
|
||||||
// customizations
|
|
||||||
// } else {
|
|
||||||
// Vec::default()
|
|
||||||
// };
|
|
||||||
// Ok(customizations)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl ViewRepository<CustomizationView, Customization> for InventoryDBPostgresAdapter {
|
impl ViewRepository<CustomizationView, Customization> for InventoryDBPostgresAdapter {
|
||||||
|
|
|
@ -76,6 +76,7 @@ impl AddCustomizationUseCase for AddCustomizationService {
|
||||||
let customization = CustomizationBuilder::default()
|
let customization = CustomizationBuilder::default()
|
||||||
.name(cmd.name().into())
|
.name(cmd.name().into())
|
||||||
.deleted(false)
|
.deleted(false)
|
||||||
|
.product_id(*cmd.product_id())
|
||||||
.customization_id(customization_id)
|
.customization_id(customization_id)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -90,7 +91,6 @@ impl AddCustomizationUseCase for AddCustomizationService {
|
||||||
|
|
||||||
Ok(CustomizationAddedEventBuilder::default()
|
Ok(CustomizationAddedEventBuilder::default()
|
||||||
.customization(customization)
|
.customization(customization)
|
||||||
.product_id(cmd.product_id().clone())
|
|
||||||
.build()
|
.build()
|
||||||
.unwrap())
|
.unwrap())
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,6 @@ pub mod tests {
|
||||||
|
|
||||||
let res = s.add_customization(cmd.clone()).await.unwrap();
|
let res = s.add_customization(cmd.clone()).await.unwrap();
|
||||||
assert_eq!(res.customization().name(), cmd.name());
|
assert_eq!(res.customization().name(), cmd.name());
|
||||||
assert_eq!(res.product_id(), cmd.product_id());
|
|
||||||
// assert_eq!(customization_added_events.len(), cmd.customizations().len());
|
// assert_eq!(customization_added_events.len(), cmd.customizations().len());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ use super::customization_aggregate::*;
|
||||||
)]
|
)]
|
||||||
pub struct CustomizationAddedEvent {
|
pub struct CustomizationAddedEvent {
|
||||||
customization: Customization,
|
customization: Customization,
|
||||||
product_id: Uuid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -31,13 +30,13 @@ pub mod tests {
|
||||||
let customization = CustomizationBuilder::default()
|
let customization = CustomizationBuilder::default()
|
||||||
.name(cmd.name().into())
|
.name(cmd.name().into())
|
||||||
.deleted(false)
|
.deleted(false)
|
||||||
|
.product_id(*cmd.product_id())
|
||||||
.customization_id(UUID.clone())
|
.customization_id(UUID.clone())
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
CustomizationAddedEventBuilder::default()
|
CustomizationAddedEventBuilder::default()
|
||||||
.customization(customization)
|
.customization(customization)
|
||||||
.product_id(cmd.product_id().clone())
|
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ use crate::inventory::application::services::InventoryServicesInterface;
|
||||||
pub struct Customization {
|
pub struct Customization {
|
||||||
name: String,
|
name: String,
|
||||||
customization_id: Uuid,
|
customization_id: Uuid,
|
||||||
|
product_id: Uuid,
|
||||||
#[builder(default = "false")]
|
#[builder(default = "false")]
|
||||||
deleted: bool,
|
deleted: bool,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue