35 lines
899 B
TypeScript
35 lines
899 B
TypeScript
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
|
|
import { PageQuery } from '../common/page.dto.js';
|
|
import { CreateTenantDto, UpdateTenantDto } from './dto.js';
|
|
import { TenantsService } from './tenants.service.js';
|
|
|
|
@Controller('tenants')
|
|
export class TenantsController {
|
|
constructor(private readonly service: TenantsService) {}
|
|
|
|
@Get()
|
|
list(@Query() q: PageQuery) {
|
|
return this.service.paginate(q.page, q.pageSize);
|
|
}
|
|
|
|
@Get(':id')
|
|
get(@Param('id') id: string) {
|
|
return this.service.findById(id);
|
|
}
|
|
|
|
@Post()
|
|
create(@Body() dto: CreateTenantDto) {
|
|
return this.service.createTenant(dto);
|
|
}
|
|
|
|
@Patch(':id')
|
|
update(@Param('id') id: string, @Body() dto: UpdateTenantDto) {
|
|
return this.service.updateTenant(id, dto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
remove(@Param('id') id: string) {
|
|
return this.service.removeTenant(id);
|
|
}
|
|
}
|