tenant.controller.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import {
  2. Body,
  3. Controller,
  4. Delete,
  5. ForbiddenException,
  6. Get,
  7. Param,
  8. Post,
  9. Put,
  10. Request,
  11. UseGuards,
  12. } from '@nestjs/common';
  13. import { TenantService } from './tenant.service';
  14. import { CombinedAuthGuard } from '../auth/combined-auth.guard';
  15. import { SuperAdminGuard } from '../auth/super-admin.guard';
  16. @Controller('tenants')
  17. @UseGuards(CombinedAuthGuard, SuperAdminGuard)
  18. export class TenantController {
  19. constructor(private readonly tenantService: TenantService) { }
  20. @Get()
  21. findAll() {
  22. return this.tenantService.findAll();
  23. }
  24. @Get(':id')
  25. findOne(@Param('id') id: string) {
  26. return this.tenantService.findById(id);
  27. }
  28. @Post()
  29. create(@Body() body: { name: string; description?: string }) {
  30. return this.tenantService.create(body.name, body.description);
  31. }
  32. @Put(':id')
  33. update(@Param('id') id: string, @Body() body: { name?: string; description?: string; isActive?: boolean }) {
  34. return this.tenantService.update(id, body);
  35. }
  36. @Delete(':id')
  37. remove(@Param('id') id: string) {
  38. return this.tenantService.remove(id);
  39. }
  40. @Get(':id/settings')
  41. getSettings(@Param('id') id: string) {
  42. return this.tenantService.getSettings(id);
  43. }
  44. @Put(':id/settings')
  45. updateSettings(@Param('id') id: string, @Body() body: any) {
  46. return this.tenantService.updateSettings(id, body);
  47. }
  48. }