Add booking dao implementations
This commit is contained in:
parent
4bca60a23c
commit
71c1432fd1
10 changed files with 225 additions and 13 deletions
|
|
@ -13,6 +13,7 @@ pub struct Booking {
|
|||
pub slot_id: Uuid,
|
||||
pub calendar_week: i32,
|
||||
pub year: u32,
|
||||
pub created: Option<PrimitiveDateTime>,
|
||||
pub deleted: Option<PrimitiveDateTime>,
|
||||
pub version: Uuid,
|
||||
}
|
||||
|
|
@ -25,23 +26,26 @@ impl From<&dao::booking::BookingEntity> for Booking {
|
|||
slot_id: booking.slot_id,
|
||||
calendar_week: booking.calendar_week,
|
||||
year: booking.year,
|
||||
created: Some(booking.created),
|
||||
deleted: booking.deleted,
|
||||
version: booking.version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Booking> for dao::booking::BookingEntity {
|
||||
fn from(booking: &Booking) -> Self {
|
||||
Self {
|
||||
impl TryFrom<&Booking> for dao::booking::BookingEntity {
|
||||
type Error = ServiceError;
|
||||
fn try_from(booking: &Booking) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
id: booking.id,
|
||||
sales_person_id: booking.sales_person_id,
|
||||
slot_id: booking.slot_id,
|
||||
calendar_week: booking.calendar_week,
|
||||
year: booking.year,
|
||||
created: booking.created.ok_or_else(|| ServiceError::InternalError)?,
|
||||
deleted: booking.deleted,
|
||||
version: booking.version,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ pub use permission::User;
|
|||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub enum ValidationFailureItem {
|
||||
ModificationNotAllowed(Arc<str>),
|
||||
InvalidValue(Arc<str>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
@ -57,4 +58,7 @@ pub enum ServiceError {
|
|||
|
||||
#[error("Date order wrong. {0} must is not smaller or equal to {1}")]
|
||||
DateOrderWrong(Date, Date),
|
||||
|
||||
#[error("Internal error")]
|
||||
InternalError,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue