felicity-lims/felicity/api/gql/storage/query.py

62 lines
2.4 KiB
Python
Raw Normal View History

from typing import List, Optional
import strawberry # noqa
2024-02-16 23:48:19 +08:00
from felicity.api.gql.permissions import IsAuthenticated
2024-02-16 23:48:19 +08:00
from felicity.api.gql.storage import types
2024-07-28 03:52:31 +08:00
from felicity.apps.storage.services import (StorageContainerService,
StorageLocationService,
StorageSectionService,
StoreRoomService)
@strawberry.type
class StorageQuery:
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def store_room_all(self, info) -> List[types.StoreRoomType]:
2024-07-26 15:29:24 +08:00
return await StoreRoomService().all()
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
2023-09-11 13:02:05 +08:00
async def store_room_by_uid(self, info, uid: str) -> Optional[types.StoreRoomType]:
2024-07-26 15:29:24 +08:00
return await StoreRoomService().get(uid=uid)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_locations(
2024-02-16 23:48:19 +08:00
self, info, store_room_uid: str
) -> List[types.StorageLocationType]:
2024-07-26 15:29:24 +08:00
return await StorageLocationService().get_all(store_room_uid=store_room_uid)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_location_by_uid(
2024-02-16 23:48:19 +08:00
self, info, uid: str
) -> Optional[types.StorageLocationType]:
2024-07-26 15:29:24 +08:00
return await StorageLocationService().get(uid=uid)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_sections(
2024-02-16 23:48:19 +08:00
self, info, storage_location_uid: str
) -> List[types.StorageSectionType]:
2024-07-26 15:29:24 +08:00
return await StorageLocationService().get_all(
storage_location_uid=storage_location_uid
)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_section_by_uid(
2024-02-16 23:48:19 +08:00
self, info, uid: str
) -> Optional[types.StorageSectionType]:
2024-07-26 15:29:24 +08:00
return await StorageSectionService().get(uid=uid)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_containers(
2024-02-16 23:48:19 +08:00
self, info, storage_section_uid: str
) -> List[types.StorageContainerType]:
2024-07-26 15:29:24 +08:00
return await StorageContainerService().get_all(
storage_section_uid=storage_section_uid
)
2023-07-26 15:23:28 +08:00
@strawberry.field(permission_classes=[IsAuthenticated])
async def storage_container_by_uid(
2024-02-16 23:48:19 +08:00
self, info, uid: str
) -> Optional[types.StorageContainerType]:
2024-07-26 15:29:24 +08:00
return await StorageContainerService().get(uid=uid)