refactor: crud mixins for repositories and services
This commit is contained in:
@ -34,8 +34,8 @@ class ServiceCreateMixin(
|
||||
|
||||
|
||||
class ServiceGetAllMixin(
|
||||
ServiceBaseMixin[RepGetAllMixin],
|
||||
Generic[EntityType, SchemaType],
|
||||
ServiceBaseMixin[RepGetAllMixin],
|
||||
):
|
||||
schema_class: type[SchemaType]
|
||||
|
||||
@ -47,8 +47,8 @@ class ServiceGetAllMixin(
|
||||
|
||||
|
||||
class ServiceUpdateMixin(
|
||||
ServiceBaseMixin[RepUpdateMixin | RepGetByIdMixin],
|
||||
Generic[EntityType, UpdateRequestType],
|
||||
ServiceBaseMixin[RepUpdateMixin | RepGetByIdMixin],
|
||||
):
|
||||
entity_not_found_msg = "Entity not found"
|
||||
entity_updated_msg = "Entity updated"
|
||||
@ -64,8 +64,8 @@ class ServiceUpdateMixin(
|
||||
|
||||
|
||||
class ServiceDeleteMixin(
|
||||
ServiceBaseMixin[RepDeleteMixin | RepGetByIdMixin],
|
||||
Generic[EntityType],
|
||||
ServiceBaseMixin[RepDeleteMixin | RepGetByIdMixin],
|
||||
):
|
||||
entity_not_found_msg = "Entity not found"
|
||||
entity_deleted_msg = "Entity deleted"
|
||||
@ -82,3 +82,13 @@ class ServiceDeleteMixin(
|
||||
|
||||
await self.repository.delete(entity, is_soft)
|
||||
return BaseDeleteResponse(message=self.entity_deleted_msg)
|
||||
|
||||
|
||||
class ServiceCrudMixin(
|
||||
Generic[EntityType, SchemaType, CreateRequestType, UpdateRequestType],
|
||||
ServiceGetAllMixin[EntityType, SchemaType],
|
||||
ServiceCreateMixin[EntityType, CreateRequestType, SchemaType],
|
||||
ServiceUpdateMixin[EntityType, UpdateRequestType],
|
||||
ServiceDeleteMixin[EntityType],
|
||||
):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user