26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import { Controller, Get, Patch, Body, UseGuards } from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { BillingService } from './billing.service';
|
|
import { UpdateBillingSettingsDto } from './dto/update-billing-settings.dto';
|
|
import { Roles } from '../common/decorators/roles.decorator';
|
|
import { RolesGuard } from '../common/guards/roles.guard';
|
|
import { TenantGuard } from '../common/guards/tenant.guard';
|
|
import { CurrentUser, CurrentUserPayload } from '../common/decorators/current-user.decorator';
|
|
|
|
@Controller('billing-settings')
|
|
@UseGuards(AuthGuard('jwt'), TenantGuard, RolesGuard)
|
|
@Roles('tenant_admin')
|
|
export class BillingController {
|
|
constructor(private readonly billingService: BillingService) {}
|
|
|
|
@Get()
|
|
async getSettings(@CurrentUser() user: CurrentUserPayload) {
|
|
return this.billingService.getSettings(user.tenantId);
|
|
}
|
|
|
|
@Patch()
|
|
async updateSettings(@CurrentUser() user: CurrentUserPayload, @Body() dto: UpdateBillingSettingsDto) {
|
|
return this.billingService.updateSettings(user.tenantId, dto);
|
|
}
|
|
}
|