From 6e479406b9aa219990dacea5b0ff56e3c4805c0f Mon Sep 17 00:00:00 2001 From: MrWaradana Date: Wed, 25 Feb 2026 16:57:46 +0700 Subject: [PATCH] add export route and add image data on response for equipment master --- src/acquisition_cost/router.py | 17 +++++++++++++++++ src/equipment/router.py | 17 +++++++++++++++++ src/equipment_master/model.py | 3 ++- src/equipment_master/router.py | 15 +++++++++++++++ src/manpower_cost/router.py | 17 +++++++++++++++++ src/manpower_master/router.py | 17 +++++++++++++++++ src/masterdata/router.py | 17 +++++++++++++++++ src/plant_masterdata/router.py | 17 +++++++++++++++++ src/plant_transaction_data/router.py | 17 +++++++++++++++++ .../router.py | 19 +++++++++++++++++++ src/simulations/router.py | 16 ++++++++++++++++ src/uploaded_file/router.py | 17 +++++++++++++++++ src/yeardata/router.py | 17 +++++++++++++++++ 13 files changed, 205 insertions(+), 1 deletion(-) diff --git a/src/acquisition_cost/router.py b/src/acquisition_cost/router.py index 194de28..7fd49a7 100644 --- a/src/acquisition_cost/router.py +++ b/src/acquisition_cost/router.py @@ -33,6 +33,23 @@ async def get_yeardatas( 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]) async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): diff --git a/src/equipment/router.py b/src/equipment/router.py index a6ea5c2..6927e5c 100644 --- a/src/equipment/router.py +++ b/src/equipment/router.py @@ -62,6 +62,23 @@ async def get_equipments( 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]]) diff --git a/src/equipment_master/model.py b/src/equipment_master/model.py index f9d64ba..c86e64b 100644 --- a/src/equipment_master/model.py +++ b/src/equipment_master/model.py @@ -31,7 +31,8 @@ class EquipmentMaster(Base, DefaultMixin): system_tag = Column(String, nullable=True) assetnum = Column(String, nullable=True) location_tag = Column(String, nullable=True) - + image_name = Column(String, nullable=True) + description = Column(String, nullable=True) # Relationship definitions # Define both sides of the relationship # parent = relationship( diff --git a/src/equipment_master/router.py b/src/equipment_master/router.py index a201d76..e843dbb 100644 --- a/src/equipment_master/router.py +++ b/src/equipment_master/router.py @@ -28,6 +28,21 @@ async def get_all_equipment_master_tree( 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( "/{equipment_master_id}", response_model=StandardResponse[EquipmentMasterRead] diff --git a/src/manpower_cost/router.py b/src/manpower_cost/router.py index d34a809..6eaa8da 100644 --- a/src/manpower_cost/router.py +++ b/src/manpower_cost/router.py @@ -32,6 +32,23 @@ async def get_yeardatas( 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]) async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): diff --git a/src/manpower_master/router.py b/src/manpower_master/router.py index d34a809..69b4929 100644 --- a/src/manpower_master/router.py +++ b/src/manpower_master/router.py @@ -32,6 +32,23 @@ async def get_yeardatas( 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]) async def get_acquisition_cost_data(db_session: DbSession, acquisition_cost_data_id: str): diff --git a/src/masterdata/router.py b/src/masterdata/router.py index b351ee3..13d1deb 100644 --- a/src/masterdata/router.py +++ b/src/masterdata/router.py @@ -40,6 +40,23 @@ async def get_masterdatas( 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]) async def get_masterdata(db_session: DbSession, masterdata_id: str): diff --git a/src/plant_masterdata/router.py b/src/plant_masterdata/router.py index f696acd..6064ce2 100644 --- a/src/plant_masterdata/router.py +++ b/src/plant_masterdata/router.py @@ -38,6 +38,23 @@ async def get_masterdatas( 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]) async def get_masterdata(db_session: DbSession, masterdata_id: str): diff --git a/src/plant_transaction_data/router.py b/src/plant_transaction_data/router.py index bd4f02c..bac841f 100644 --- a/src/plant_transaction_data/router.py +++ b/src/plant_transaction_data/router.py @@ -49,6 +49,23 @@ async def get_transaction_datas( 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]) async def get_chart_data(db_session: DbSession, common: CommonParameters): chart_data, bep_year, bep_total_lcc = await get_charts( diff --git a/src/plant_transaction_data_simulations/router.py b/src/plant_transaction_data_simulations/router.py index bd6a16c..afe05cf 100644 --- a/src/plant_transaction_data_simulations/router.py +++ b/src/plant_transaction_data_simulations/router.py @@ -52,6 +52,25 @@ async def get_transaction_datas( 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]) async def get_chart_data( db_session: DbSession, diff --git a/src/simulations/router.py b/src/simulations/router.py index 50b1d3b..26c3faf 100644 --- a/src/simulations/router.py +++ b/src/simulations/router.py @@ -36,6 +36,22 @@ async def get_simulations( ) 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]) async def get_simulation( diff --git a/src/uploaded_file/router.py b/src/uploaded_file/router.py index d03b1b0..e3232dc 100644 --- a/src/uploaded_file/router.py +++ b/src/uploaded_file/router.py @@ -36,6 +36,23 @@ async def get_uploaded_files( 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]) async def get_uploaded_file(db_session: DbSession, uploaded_file_id: str): diff --git a/src/yeardata/router.py b/src/yeardata/router.py index b92d443..8a536aa 100644 --- a/src/yeardata/router.py +++ b/src/yeardata/router.py @@ -33,6 +33,23 @@ async def get_yeardatas( 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]) async def get_yeardata(db_session: DbSession, yeardata_id: str):