orgs.controller.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common'
  2. import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard'
  3. import { CurrentUser } from '../../common/decorators/current-user.decorator'
  4. import { OrgsService } from './orgs.service'
  5. import { CreateOrgDto, UpdateOrgDto } from './dto/org.dto'
  6. @Controller('orgs')
  7. @UseGuards(JwtAuthGuard)
  8. export class OrgsController {
  9. constructor(private readonly orgsService: OrgsService) {}
  10. @Post()
  11. create(@Body() dto: CreateOrgDto) {
  12. return this.orgsService.create(dto)
  13. }
  14. @Get()
  15. findAll() {
  16. return this.orgsService.findAll()
  17. }
  18. @Get(':id')
  19. findOne(@Param('id') id: string) {
  20. return this.orgsService.findOne(id)
  21. }
  22. @Patch(':id')
  23. update(@Param('id') id: string, @Body() dto: UpdateOrgDto) {
  24. return this.orgsService.update(id, dto)
  25. }
  26. @Delete(':id')
  27. remove(@Param('id') id: string) {
  28. return this.orgsService.remove(id)
  29. }
  30. @Get(':id/me-access')
  31. myAccess(@Param('id') orgId: string, @CurrentUser() user: { userId: string }) {
  32. return this.orgsService.ensureUserInOrg(user.userId, orgId)
  33. }
  34. }