1
from typing import Any, Optional
3
from sqlalchemy.ext.asyncio import AsyncSession
4
from starlette.requests import Request
5
from app.inventory.location.models.location_models import Location
6
from app.inventory.location.schemas.location_schemas import LocationCreateScheme, LocationUpdateScheme, LocationFilter
7
from core.permissions import permit
8
from core.service.base import BaseService, UpdateSchemaType, ModelType, FilterSchemaType, CreateSchemaType
11
class LocationService(BaseService[Location, LocationCreateScheme, LocationUpdateScheme, LocationFilter]):
12
def __init__(self, request:Request):
13
super(LocationService, self).__init__(request, Location,LocationCreateScheme, LocationUpdateScheme)
15
@permit('location_edit')
16
async def update(self, id: Any, obj: UpdateSchemaType) -> Optional[ModelType]:
17
return await super(LocationService, self).update(id, obj)
19
@permit('location_list')
20
async def list(self, _filter: FilterSchemaType, size: int = None):
21
return await super(LocationService, self).list(_filter, size)
23
@permit('location_create')
24
async def create(self, obj: CreateSchemaType) -> ModelType:
25
return await super(LocationService, self).create(obj)
27
@permit('location_delete')
28
async def delete(self, id: Any) -> None:
29
return await super(LocationService, self).delete(id)