// src/modules/customers/customers.controller.ts import { Controller, Delete, Get, HttpCode, HttpStatus, Param, ParseUUIDPipe, Patch, Post, Body, Query, } from "@nestjs/common"; import { ApiOperation } from "@nestjs/swagger"; import { FreightAdmin } from "../../common/booking-guards"; import { CustomersService } from "./customers.service"; import { CreateCustomerDto } from "./dto/create-customer.dto"; import { UpdateCustomerDto } from "./dto/update-customer.dto"; import { Customer } from "./entities/customer.entity"; @Controller("customers") @FreightAdmin() export class CustomersController { constructor(private readonly customersService: CustomersService) {} @Post() create(@Body() createCustomerDto: CreateCustomerDto): Promise { return this.customersService.create(createCustomerDto); } @Get() findAll(): Promise { return this.customersService.findAll(); } @Get("stats") @ApiOperation({ summary: "Get customer statistics" }) getStats(): Promise<{ total: number; withVatNumber: number }> { return this.customersService.getStats(); } @Get("search") searchByName(@Query("name") name: string): Promise { return this.customersService.searchByName(name); } @Get("email/:email") findByEmail(@Param("email") email: string): Promise { return this.customersService.findByEmail(email); } @Get("vat/:vatNumber") findByVatNumber(@Param("vatNumber") vatNumber: string): Promise { return this.customersService.findByVatNumber(vatNumber); } @Get(":id") findById(@Param("id", ParseUUIDPipe) id: string): Promise { return this.customersService.findById(id); } // @Get("user/:userId") // findByUserId(@Param("userId", ParseUUIDPipe) userId: string): Promise { // return this.customersService.findByUserId(userId); // } @Patch(":id") @ApiOperation({ summary: "Update a customer" }) update( @Param("id", ParseUUIDPipe) id: string, @Body() dto: UpdateCustomerDto, ): Promise { return this.customersService.update(id, dto); } @Delete(":id") @ApiOperation({ summary: "Soft-delete a customer" }) @HttpCode(HttpStatus.NO_CONTENT) remove(@Param("id", ParseUUIDPipe) id: string): Promise { return this.customersService.delete(id); } }