Add REST endpoint for slot

This commit is contained in:
Simon Goller 2024-05-02 23:25:04 +02:00
parent 82e89baeeb
commit 8f378472ea
28 changed files with 1925 additions and 28 deletions

View file

@ -5,15 +5,25 @@ use sqlx::SqlitePool;
type PermissionService =
service_impl::PermissionServiceImpl<dao_impl::PermissionDaoImpl, service_impl::UserServiceDev>;
type HelloService = service_impl::HelloServiceImpl<dao_impl::HelloDaoImpl, PermissionService>;
type ClockService = service_impl::clock::ClockServiceImpl;
type UuidService = service_impl::uuid_service::UuidServiceImpl;
type SlotService = service_impl::slot::SlotServiceImpl<
dao_impl::slot::SlotDaoImpl,
PermissionService,
ClockService,
UuidService,
>;
#[derive(Clone)]
pub struct RestStateImpl {
hello_service: Arc<HelloService>,
permission_service: Arc<PermissionService>,
slot_service: Arc<SlotService>,
}
impl rest::RestStateDef for RestStateImpl {
type HelloService = HelloService;
type PermissionService = PermissionService;
type SlotService = SlotService;
fn hello_service(&self) -> Arc<Self::HelloService> {
self.hello_service.clone()
@ -21,11 +31,15 @@ impl rest::RestStateDef for RestStateImpl {
fn permission_service(&self) -> Arc<Self::PermissionService> {
self.permission_service.clone()
}
fn slot_service(&self) -> Arc<Self::SlotService> {
self.slot_service.clone()
}
}
impl RestStateImpl {
pub fn new(pool: Arc<sqlx::Pool<sqlx::Sqlite>>) -> Self {
let hello_dao = dao_impl::HelloDaoImpl::new(pool.clone());
let permission_dao = dao_impl::PermissionDaoImpl::new(pool);
let permission_dao = dao_impl::PermissionDaoImpl::new(pool.clone());
let slot_dao = dao_impl::slot::SlotDaoImpl::new(pool);
// Always authenticate with DEVUSER during development.
// This is used to test the permission service locally without a login service.
@ -42,9 +56,18 @@ impl RestStateImpl {
hello_dao.into(),
permission_service.clone(),
));
let clock_service = Arc::new(service_impl::clock::ClockServiceImpl);
let uuid_service = Arc::new(service_impl::uuid_service::UuidServiceImpl);
let slot_service = Arc::new(service_impl::slot::SlotServiceImpl::new(
slot_dao.into(),
permission_service.clone(),
clock_service,
uuid_service,
));
Self {
hello_service,
permission_service,
slot_service,
}
}
}