add export route and add image data on response for equipment master

main^2
MrWaradana 2 weeks ago
parent 7a4050ee4a
commit 6e479406b9

@ -33,6 +33,23 @@ async def get_yeardatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[AcquisitionCostDataPagination])
async def get_yeardatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all acquisition_cost_data for export."""
common["all"] = True
get_acquisition_cost_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=get_acquisition_cost_data,
message="All Acquisition Cost Data retrieved successfully",
)
@router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[AcquisitionCostDataRead]) @router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[AcquisitionCostDataRead])
async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str):

@ -62,6 +62,23 @@ async def get_equipments(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[EquipmentPagination])
async def get_equipments_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all equipment for export."""
common["all"] = True
equipment_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=equipment_data,
message="All Equipment Data retrieved successfully",
)
@router.get("/maximo/{assetnum}", response_model=StandardResponse[List[dict]]) @router.get("/maximo/{assetnum}", response_model=StandardResponse[List[dict]])

@ -31,7 +31,8 @@ class EquipmentMaster(Base, DefaultMixin):
system_tag = Column(String, nullable=True) system_tag = Column(String, nullable=True)
assetnum = Column(String, nullable=True) assetnum = Column(String, nullable=True)
location_tag = Column(String, nullable=True) location_tag = Column(String, nullable=True)
image_name = Column(String, nullable=True)
description = Column(String, nullable=True)
# Relationship definitions # Relationship definitions
# Define both sides of the relationship # Define both sides of the relationship
# parent = relationship( # parent = relationship(

@ -28,6 +28,21 @@ async def get_all_equipment_master_tree(
data=equipment_masters, message="Data retrieved successfully" data=equipment_masters, message="Data retrieved successfully"
) )
@router.get("/export-all", response_model=StandardResponse[EquipmentMasterPaginated])
async def get_all_equipment_master_tree_export_all(
db_session: DbSession,
common: CommonParameters,
):
common["all"] = True
equipment_masters = await get_all_master(
db_session=db_session,
common=common,
)
return StandardResponse(
data=equipment_masters, message="All Equipment Master Data retrieved successfully"
)
@router.get( @router.get(
"/{equipment_master_id}", response_model=StandardResponse[EquipmentMasterRead] "/{equipment_master_id}", response_model=StandardResponse[EquipmentMasterRead]

@ -32,6 +32,23 @@ async def get_yeardatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[ManpowerCostPagination])
async def get_yeardatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all manpower_cost_data for export."""
common["all"] = True
get_acquisition_cost_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=get_acquisition_cost_data,
message="All Manpower Cost Data retrieved successfully",
)
@router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[ManpowerCostRead]) @router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[ManpowerCostRead])
async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str):

@ -32,6 +32,23 @@ async def get_yeardatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[ManpowerCostPagination])
async def get_yeardatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all manpower_master_data for export."""
common["all"] = True
get_acquisition_cost_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=get_acquisition_cost_data,
message="All Manpower Master Data retrieved successfully",
)
@router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[ManpowerCostRead]) @router.get("/{acquisition_cost_data_id}", response_model=StandardResponse[ManpowerCostRead])
async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str):

@ -40,6 +40,23 @@ async def get_masterdatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[MasterDataPagination])
async def get_masterdatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all documents for export."""
common["all"] = True
master_datas = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=master_datas,
message="All Master Data retrieved successfully",
)
@router.get("/{masterdata_id}", response_model=StandardResponse[MasterDataRead]) @router.get("/{masterdata_id}", response_model=StandardResponse[MasterDataRead])
async def get_masterdata(db_session: DbSession, masterdata_id: str): async def get_masterdata(db_session: DbSession, masterdata_id: str):

@ -38,6 +38,23 @@ async def get_masterdatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[PlantMasterDataPagination])
async def get_masterdatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all documents for export."""
common["all"] = True
master_datas = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=master_datas,
message="All Plant Master Data retrieved successfully",
)
@router.get("/{masterdata_id}", response_model=StandardResponse[PlantMasterDataRead]) @router.get("/{masterdata_id}", response_model=StandardResponse[PlantMasterDataRead])
async def get_masterdata(db_session: DbSession, masterdata_id: str): async def get_masterdata(db_session: DbSession, masterdata_id: str):

@ -49,6 +49,23 @@ async def get_transaction_datas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[PlantTransactionDataPagination])
async def get_transaction_datas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all transaction_data for export."""
common["all"] = True
plant_transaction_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=plant_transaction_data,
message="All Plant Transaction Data retrieved successfully",
)
@router.get("/charts", response_model=StandardResponse[PlantChartData]) @router.get("/charts", response_model=StandardResponse[PlantChartData])
async def get_chart_data(db_session: DbSession, common: CommonParameters): async def get_chart_data(db_session: DbSession, common: CommonParameters):
chart_data, bep_year, bep_total_lcc = await get_charts( chart_data, bep_year, bep_total_lcc = await get_charts(

@ -52,6 +52,25 @@ async def get_transaction_datas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[PlantTransactionDataSimulationsPagination])
async def get_transaction_datas_export_all(
db_session: DbSession,
common: CommonParameters,
simulation_id: UUID = Query(..., description="Simulation identifier"),
):
"""Get all transaction_data for export."""
common["all"] = True
plant_transaction_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
simulation_id=simulation_id,
)
return StandardResponse(
data=plant_transaction_data,
message="All Plant Transaction Data Simulations retrieved successfully",
)
@router.get("/charts", response_model=StandardResponse[PlantChartDataSimulations]) @router.get("/charts", response_model=StandardResponse[PlantChartDataSimulations])
async def get_chart_data( async def get_chart_data(
db_session: DbSession, db_session: DbSession,

@ -36,6 +36,22 @@ async def get_simulations(
) )
return StandardResponse(data=simulations, message="Data retrieved successfully") return StandardResponse(data=simulations, message="Data retrieved successfully")
@router.get("/export-all", response_model=StandardResponse[SimulationPagination])
async def get_simulations_export_all(
db_session: DbSession,
common: CommonParameters,
current_user: CurrentUser,
):
"""Get all simulations for export."""
common["all"] = True
simulations = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
owner=current_user.name,
)
return StandardResponse(data=simulations, message="All Simulations Data retrieved successfully")
@router.get("/{simulation_id}", response_model=StandardResponse[SimulationRead]) @router.get("/{simulation_id}", response_model=StandardResponse[SimulationRead])
async def get_simulation( async def get_simulation(

@ -36,6 +36,23 @@ async def get_uploaded_files(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[UploadedFileDataPagination])
async def get_uploaded_files_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all uploaded files for export."""
common["all"] = True
uploaded_files = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=uploaded_files,
message="All Uploaded Files Data retrieved successfully",
)
@router.get("/{uploaded_file_id}", response_model=StandardResponse[UploadedFileDataRead]) @router.get("/{uploaded_file_id}", response_model=StandardResponse[UploadedFileDataRead])
async def get_uploaded_file(db_session: DbSession, uploaded_file_id: str): async def get_uploaded_file(db_session: DbSession, uploaded_file_id: str):

@ -33,6 +33,23 @@ async def get_yeardatas(
message="Data retrieved successfully", message="Data retrieved successfully",
) )
@router.get("/export-all", response_model=StandardResponse[YeardataPagination])
async def get_yeardatas_export_all(
db_session: DbSession,
common: CommonParameters,
):
"""Get all yeardata for export."""
common["all"] = True
year_data = await get_all(
db_session=db_session,
items_per_page=-1,
common=common,
)
return StandardResponse(
data=year_data,
message="All Year Data retrieved successfully",
)
@router.get("/{yeardata_id}", response_model=StandardResponse[YeardataRead]) @router.get("/{yeardata_id}", response_model=StandardResponse[YeardataRead])
async def get_yeardata(db_session: DbSession, yeardata_id: str): async def get_yeardata(db_session: DbSession, yeardata_id: str):

Loading…
Cancel
Save