You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
from typing import Dict, List, Optional
|
|
|
|
from fastapi import APIRouter, HTTPException, Query, status
|
|
|
|
from src.database.service import (CommonParameters, DbSession,
|
|
search_filter_sort_paginate)
|
|
from src.models import StandardResponse
|
|
|
|
from .schema import ScopeEquipmentJobCreate, ScopeEquipmentJobPagination
|
|
from .service import create, delete, get_all
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get(
|
|
"/{location_tag}", response_model=StandardResponse[ScopeEquipmentJobPagination]
|
|
)
|
|
async def get_jobs(common: CommonParameters, location_tag: str, scope: Optional[str] = Query(None)):
|
|
"""Get all scope pagination."""
|
|
# return
|
|
results = await get_all(common=common, location_tag=location_tag, scope=scope)
|
|
|
|
return StandardResponse(
|
|
data=results,
|
|
message="Data retrieved successfully",
|
|
)
|
|
|
|
|
|
@router.post("/{assetnum}", response_model=StandardResponse[None])
|
|
async def create_scope_equipment_jobs(
|
|
db_session: DbSession, assetnum, scope_job_in: ScopeEquipmentJobCreate
|
|
):
|
|
"""Get all scope activity pagination."""
|
|
# return
|
|
await create(db_session=db_session, assetnum=assetnum, scope_job_in=scope_job_in)
|
|
|
|
return StandardResponse(
|
|
data=None,
|
|
message="Data created successfully",
|
|
)
|
|
|
|
|
|
@router.delete("/{scope_job_id}", response_model=StandardResponse[None])
|
|
async def delete_scope_equipment_job(db_session: DbSession, scope_job_id):
|
|
|
|
await delete(db_session=db_session, scope_job_id=scope_job_id)
|
|
|
|
return StandardResponse(
|
|
data=None,
|
|
message="Data deleted successfully",
|
|
)
|