mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 10:40:58 +00:00
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { Body, Controller, Delete, Get, HttpCode, Param, Patch, Post, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { CurrenciesService } from './currencies.service';
|
|
import { CreateCurrencyDto, UpdateCurrencyDto } from './currencies.dto';
|
|
import { PassengerAdmin, PassengerStaff } from '../../common/passenger-guards';
|
|
import { PASSENGER_PERMS } from '../../seed/passenger-permissions.registry';
|
|
|
|
@ApiTags('Currencies')
|
|
@Controller('currencies')
|
|
export class CurrenciesController {
|
|
constructor(private currenciesService: CurrenciesService) {}
|
|
|
|
@Get()
|
|
getAllCurrencies() {
|
|
return this.currenciesService.getAllCurrencies();
|
|
}
|
|
|
|
@Post()
|
|
@PassengerStaff(PASSENGER_PERMS.currencies.manage)
|
|
@ApiBearerAuth('IAM-auth')
|
|
@HttpCode(201)
|
|
createCurrency(@Body() dto: CreateCurrencyDto) {
|
|
return this.currenciesService.createCurrency(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@PassengerStaff(PASSENGER_PERMS.currencies.manage)
|
|
@ApiBearerAuth('IAM-auth')
|
|
updateCurrency(@Param('id') id: string, @Body() dto: UpdateCurrencyDto) {
|
|
return this.currenciesService.updateCurrency(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@PassengerAdmin()
|
|
@ApiBearerAuth('IAM-auth')
|
|
deleteCurrency(@Param('id') id: string) {
|
|
return this.currenciesService.deleteCurrency(id);
|
|
}
|
|
|
|
@Post('sync-rates')
|
|
@PassengerStaff(PASSENGER_PERMS.currencies.manage)
|
|
@ApiBearerAuth('IAM-auth')
|
|
@HttpCode(200)
|
|
syncRates() {
|
|
return this.currenciesService.syncExchangeRates();
|
|
}
|
|
}
|