Cargo clippy and cargo fmt
This commit is contained in:
parent
b0000c0117
commit
ed609cf06c
22 changed files with 286 additions and 94 deletions
|
|
@ -1,12 +1,12 @@
|
|||
use std::sync::Arc;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use time::PrimitiveDateTime;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::ServiceError;
|
||||
use crate::permission::Authentication;
|
||||
use crate::ServiceError;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Booking {
|
||||
|
|
@ -55,12 +55,23 @@ impl TryFrom<&Booking> for dao::booking::BookingEntity {
|
|||
pub trait BookingService {
|
||||
type Context: Clone + PartialEq + Eq + Debug + Send + Sync;
|
||||
|
||||
async fn get_all(&self, context: Authentication<Self::Context>) -> Result<Arc<[Booking]>, ServiceError>;
|
||||
async fn get(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<Booking, ServiceError>;
|
||||
async fn get_all(
|
||||
&self,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Arc<[Booking]>, ServiceError>;
|
||||
async fn get(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Booking, ServiceError>;
|
||||
async fn create(
|
||||
&self,
|
||||
booking: &Booking,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Booking, ServiceError>;
|
||||
async fn delete(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn delete(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
|
|
@ -43,11 +43,13 @@ impl From<&dao::PrivilegeEntity> for Privilege {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Authentication<Context: Clone + PartialEq + Eq + Send + Sync + Debug + 'static>{
|
||||
pub enum Authentication<Context: Clone + PartialEq + Eq + Send + Sync + Debug + 'static> {
|
||||
Full,
|
||||
Context(Context),
|
||||
}
|
||||
impl<Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static> From<Context> for Authentication<Context> {
|
||||
impl<Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static> From<Context>
|
||||
for Authentication<Context>
|
||||
{
|
||||
fn from(context: Context) -> Self {
|
||||
Self::Context(context)
|
||||
}
|
||||
|
|
@ -64,14 +66,40 @@ pub trait PermissionService {
|
|||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
|
||||
async fn create_user(&self, user: &str, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn user_exists(&self, user: &str, context: Authentication<Self::Context>) -> Result<bool, ServiceError>;
|
||||
async fn delete_user(&self, user: &str, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn get_all_users(&self, context: Authentication<Self::Context>) -> Result<Arc<[User]>, ServiceError>;
|
||||
async fn create_user(
|
||||
&self,
|
||||
user: &str,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn user_exists(
|
||||
&self,
|
||||
user: &str,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<bool, ServiceError>;
|
||||
async fn delete_user(
|
||||
&self,
|
||||
user: &str,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn get_all_users(
|
||||
&self,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Arc<[User]>, ServiceError>;
|
||||
|
||||
async fn create_role(&self, role: &str, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn delete_role(&self, role: &str, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn get_all_roles(&self, context: Authentication<Self::Context>) -> Result<Arc<[Role]>, ServiceError>;
|
||||
async fn create_role(
|
||||
&self,
|
||||
role: &str,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn delete_role(
|
||||
&self,
|
||||
role: &str,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn get_all_roles(
|
||||
&self,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Arc<[Role]>, ServiceError>;
|
||||
|
||||
async fn create_privilege(
|
||||
&self,
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use std::sync::Arc;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::ServiceError;
|
||||
use crate::permission::Authentication;
|
||||
use crate::ServiceError;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct SalesPerson {
|
||||
|
|
@ -44,9 +44,20 @@ impl From<&SalesPerson> for dao::sales_person::SalesPersonEntity {
|
|||
pub trait SalesPersonService {
|
||||
type Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static;
|
||||
|
||||
async fn get_all(&self, context: Authentication<Self::Context>) -> Result<Arc<[SalesPerson]>, ServiceError>;
|
||||
async fn get(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<SalesPerson, ServiceError>;
|
||||
async fn exists(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<bool, ServiceError>;
|
||||
async fn get_all(
|
||||
&self,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Arc<[SalesPerson]>, ServiceError>;
|
||||
async fn get(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<SalesPerson, ServiceError>;
|
||||
async fn exists(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<bool, ServiceError>;
|
||||
async fn create(
|
||||
&self,
|
||||
item: &SalesPerson,
|
||||
|
|
@ -57,7 +68,11 @@ pub trait SalesPersonService {
|
|||
item: &SalesPerson,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<SalesPerson, ServiceError>;
|
||||
async fn delete(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn delete(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn get_assigned_user(
|
||||
&self,
|
||||
sales_person_id: Uuid,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
use std::fmt::Debug;
|
||||
|
||||
use crate::ServiceError;
|
||||
use crate::permission::Authentication;
|
||||
use crate::ServiceError;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum DayOfWeek {
|
||||
|
|
@ -89,10 +89,33 @@ impl From<&Slot> for dao::slot::SlotEntity {
|
|||
pub trait SlotService {
|
||||
type Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static;
|
||||
|
||||
async fn get_slots(&self, context: Authentication<Self::Context>) -> Result<Arc<[Slot]>, ServiceError>;
|
||||
async fn get_slot(&self, id: &Uuid, context: Authentication<Self::Context>) -> Result<Slot, ServiceError>;
|
||||
async fn exists(&self, id: Uuid, context: Authentication<Self::Context>) -> Result<bool, ServiceError>;
|
||||
async fn create_slot(&self, slot: &Slot, context: Authentication<Self::Context>) -> Result<Slot, ServiceError>;
|
||||
async fn delete_slot(&self, id: &Uuid, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn update_slot(&self, slot: &Slot, context: Authentication<Self::Context>) -> Result<(), ServiceError>;
|
||||
async fn get_slots(
|
||||
&self,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Arc<[Slot]>, ServiceError>;
|
||||
async fn get_slot(
|
||||
&self,
|
||||
id: &Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Slot, ServiceError>;
|
||||
async fn exists(
|
||||
&self,
|
||||
id: Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<bool, ServiceError>;
|
||||
async fn create_slot(
|
||||
&self,
|
||||
slot: &Slot,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<Slot, ServiceError>;
|
||||
async fn delete_slot(
|
||||
&self,
|
||||
id: &Uuid,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
async fn update_slot(
|
||||
&self,
|
||||
slot: &Slot,
|
||||
context: Authentication<Self::Context>,
|
||||
) -> Result<(), ServiceError>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::sync::Arc;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use mockall::automock;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue