import { Body, Controller, Get, Post, Query } from '@nestjs/common'
import { FuelService } from './fuel.service'
import { CreateExpenseDto } from './dto/create-expense'
import { CreateLimitDto } from './dto/create-limit'
import { CreateTransferDto } from './dto/create-transfer'
import { FuelLimitDto } from './dto/limit'
import { ApiOkResponse } from '@nestjs/swagger'
import { FuelExpenseDto } from './dto/expense'
import { FuelTransferDto } from './dto/transfer'
import { GetBoilersDTO } from './dto/get-boilers'
import { GetFuelsDTO } from './dto/get-fuels'
import { GetLimitsDTO } from './dto/get-limits'
import { GetCitySettingsDTO } from './dto/get-city-settings'

@Controller('fuel')
export class FuelController {
    constructor(private readonly fuelService: FuelService) { }

    @Get('/columns')
    async getColumnDataTypes() {
        return this.fuelService.getColumnDataTypes('BoilersFuelsExpenses')
    }

    @Get('/boilers')//✅
    async getBoilers(@Query() getBoilersDTO: GetBoilersDTO) {
        const { city_id, offset, limit } = getBoilersDTO
        return this.fuelService.getBoilers(city_id, offset, limit)
    }

    @Get('/fuel-types')
    async getFuelTypes() {
        return this.fuelService.getFuelTypes()
    }

    @Get('/fuels')
    async getFuels(@Query() getFuelsDTO: GetFuelsDTO) {
        const { id_fuels, offset, limit } = getFuelsDTO
        return this.fuelService.getFuels(id_fuels)
    }

    // Fuel limits
    @Get('/limits')
    @ApiOkResponse({
        description: 'List of fuel expenses',
        type: FuelLimitDto,
        isArray: true,
    })
    async getBoilersFuelsLimits(@Query() getLimitsDTO: GetLimitsDTO): Promise<FuelLimitDto[]> {
        return this.fuelService.getBoilersFuelsLimits(getLimitsDTO)
    }

    @Post('/limits')
    async addBoilersFuelsLimit(@Body() createLimitDto: CreateLimitDto) {
        return this.fuelService.addBoilersFuelsLimit(createLimitDto)
    }

    // Fuel limits
    @Get('/city-settings')
    @ApiOkResponse({
        description: 'City settings',
        isArray: true,
    })
    async getCitySettings(@Query() getCitySettingsDTO: GetCitySettingsDTO): Promise<any[]> {
        return this.fuelService.getCitySettings(getCitySettingsDTO)
    }

    // Fuel expenses
    @Get('/expenses')
    @ApiOkResponse({
        description: 'List of fuel expenses',
        type: FuelExpenseDto,
        isArray: true,
    })
    async getBoilersFuelsExpenses(): Promise<FuelExpenseDto[]> {
        return this.fuelService.getBoilersFuelsExpenses()
    }

    @Post('/expenses')
    async addBoilersFuelsExpense(@Body() createExpenseDto: CreateExpenseDto) {
        return this.fuelService.addBoilersFuelsExpense(createExpenseDto)
    }


    // Fuel transfer
    @Get('/transfer')
    @ApiOkResponse({
        description: 'List of fuel expenses',
        type: FuelTransferDto,
        isArray: true,
    })
    async getFuelsTransfer(): Promise<FuelTransferDto[]> {
        return this.fuelService.getFuelsTransfer()
    }

    @Post('/transfer')
    async addFuelTransfer(@Body() createTransferDto: CreateTransferDto) {
        return this.fuelService.addFuelsTransfer(createTransferDto)
    }
}