mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
HttpStatus,
|
|
Param,
|
|
ParseUUIDPipe,
|
|
Patch,
|
|
Post,
|
|
} from "@nestjs/common";
|
|
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
|
|
|
import { CustomersService } from "./customers.service";
|
|
import { CreateCustomerDto } from "./dto/create-customer.dto";
|
|
import { UpdateCustomerDto } from "./dto/update-customer.dto";
|
|
|
|
@ApiTags("customers")
|
|
@Controller("customers")
|
|
export class CustomersController {
|
|
constructor(private readonly customersService: CustomersService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: "Create a new customer" })
|
|
create(@Body() dto: CreateCustomerDto) {
|
|
return this.customersService.create(dto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: "List all customers" })
|
|
findAll() {
|
|
return this.customersService.findAll();
|
|
}
|
|
|
|
@Get(":id")
|
|
@ApiOperation({ summary: "Get a customer by ID" })
|
|
findOne(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.customersService.findById(id);
|
|
}
|
|
|
|
@Patch(":id")
|
|
@ApiOperation({ summary: "Update a customer" })
|
|
update(
|
|
@Param("id", ParseUUIDPipe) id: string,
|
|
@Body() dto: UpdateCustomerDto,
|
|
) {
|
|
return this.customersService.update(id, dto);
|
|
}
|
|
|
|
@Delete(":id")
|
|
@ApiOperation({ summary: "Soft-delete a customer" })
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
remove(@Param("id", ParseUUIDPipe) id: string) {
|
|
return this.customersService.remove(id);
|
|
}
|
|
}
|