mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
feat: add fuel management system backend
- FuelPurchase entity: record fuel purchases with cost tracking - FuelConsumption entity: monthly aggregation of fuel metrics - FuelService: record purchases, calculate stats, efficiency - FuelController: REST API for fuel operations - FuelModule: integrated into app - Migration: create fuel_purchases and fuel_consumption tables Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
48
apps/edr-freight-api/src/modules/fuel/fuel.controller.ts
Normal file
48
apps/edr-freight-api/src/modules/fuel/fuel.controller.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Controller, Post, Get, Body, Param, Query } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||
import { FuelService } from './fuel.service';
|
||||
import { CreateFuelPurchaseDto } from './dto/create-fuel-purchase.dto';
|
||||
|
||||
@ApiTags('Fuel Management')
|
||||
@Controller('fuel')
|
||||
export class FuelController {
|
||||
constructor(private readonly fuelService: FuelService) {}
|
||||
|
||||
@Post('purchases')
|
||||
@ApiOperation({ summary: 'Record fuel purchase' })
|
||||
async recordFuelPurchase(@Body() dto: CreateFuelPurchaseDto) {
|
||||
return this.fuelService.recordFuelPurchase(dto);
|
||||
}
|
||||
|
||||
@Get('purchases/:vehicleId')
|
||||
@ApiOperation({ summary: 'Get fuel purchases for vehicle' })
|
||||
async getFuelPurchases(
|
||||
@Param('vehicleId') vehicleId: string,
|
||||
@Query('startDate') startDate: string,
|
||||
@Query('endDate') endDate: string,
|
||||
) {
|
||||
return this.fuelService.getFuelPurchases(
|
||||
vehicleId,
|
||||
new Date(startDate),
|
||||
new Date(endDate),
|
||||
);
|
||||
}
|
||||
|
||||
@Get('consumption/:vehicleId/:month')
|
||||
@ApiOperation({ summary: 'Get monthly fuel consumption' })
|
||||
async getMonthlyConsumption(
|
||||
@Param('vehicleId') vehicleId: string,
|
||||
@Param('month') month: string,
|
||||
) {
|
||||
return this.fuelService.getMonthlyConsumption(vehicleId, new Date(month));
|
||||
}
|
||||
|
||||
@Get('stats/:vehicleId')
|
||||
@ApiOperation({ summary: 'Get fuel statistics for vehicle' })
|
||||
async getVehicleFuelStats(
|
||||
@Param('vehicleId') vehicleId: string,
|
||||
@Query('months') months: number = 12,
|
||||
) {
|
||||
return this.fuelService.getVehicleFuelStats(vehicleId, months);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user