2023-05-12 02:32:50 +08:00
|
|
|
from typing import List, Optional
|
|
|
|
|
|
|
|
import strawberry # noqa
|
2024-02-16 23:48:19 +08:00
|
|
|
|
2024-01-27 01:08:02 +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)
|
2023-05-12 02:32:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
@strawberry.type
|
|
|
|
class StorageQuery:
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def store_room_all(self, info) -> List[types.StoreRoomType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StoreRoomService().all()
|
2023-05-12 02:32:50 +08:00
|
|
|
|
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-05-12 02:32:50 +08:00
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_locations(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, store_room_uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> List[types.StorageLocationType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageLocationService().get_all(store_room_uid=store_room_uid)
|
2023-05-12 02:32:50 +08:00
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_location_by_uid(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> Optional[types.StorageLocationType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageLocationService().get(uid=uid)
|
2023-05-12 02:32:50 +08:00
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_sections(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, storage_location_uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> List[types.StorageSectionType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageLocationService().get_all(
|
2023-05-12 02:32:50 +08:00
|
|
|
storage_location_uid=storage_location_uid
|
|
|
|
)
|
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_section_by_uid(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> Optional[types.StorageSectionType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageSectionService().get(uid=uid)
|
2023-05-12 02:32:50 +08:00
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_containers(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, storage_section_uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> List[types.StorageContainerType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageContainerService().get_all(
|
2023-05-12 02:32:50 +08:00
|
|
|
storage_section_uid=storage_section_uid
|
|
|
|
)
|
|
|
|
|
2023-07-26 15:23:28 +08:00
|
|
|
@strawberry.field(permission_classes=[IsAuthenticated])
|
2023-05-12 02:32:50 +08:00
|
|
|
async def storage_container_by_uid(
|
2024-02-16 23:48:19 +08:00
|
|
|
self, info, uid: str
|
2023-05-12 02:32:50 +08:00
|
|
|
) -> Optional[types.StorageContainerType]:
|
2024-07-26 15:29:24 +08:00
|
|
|
return await StorageContainerService().get(uid=uid)
|