36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Body, Controller, Get, Patch, UseGuards } from '@nestjs/common';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { RolesGuard } from '../auth/roles.guard';
|
|
import { Roles } from '../auth/roles.decorator';
|
|
import { CurrentUser } from '../auth/current-user.decorator';
|
|
import { UpdateOrgCurrenciesDto } from './dto';
|
|
import { OrganizationsService } from './organizations.service';
|
|
|
|
@Controller('organizations')
|
|
@UseGuards(JwtAuthGuard, RolesGuard)
|
|
export class OrganizationsController {
|
|
constructor(private readonly organizationsService: OrganizationsService) {}
|
|
|
|
@Get('current')
|
|
current(@CurrentUser() user: { organizationId: string }) {
|
|
return this.organizationsService.getCurrent(user.organizationId);
|
|
}
|
|
|
|
@Get('currency-catalog')
|
|
catalog() {
|
|
return this.organizationsService.catalog();
|
|
}
|
|
|
|
@Patch('current/currencies')
|
|
@Roles('owner', 'admin')
|
|
updateCurrencies(
|
|
@CurrentUser() user: { organizationId: string },
|
|
@Body() dto: UpdateOrgCurrenciesDto,
|
|
) {
|
|
return this.organizationsService.updateCurrencies(
|
|
user.organizationId,
|
|
dto,
|
|
);
|
|
}
|
|
}
|