Uecko_ERP/modules/customer-invoices/src/api/infrastructure/express/controllers/delete-customer-invoice.controller.ts

26 lines
854 B
TypeScript
Raw Normal View History

2025-08-26 18:55:59 +00:00
import { ExpressController, authGuard, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api";
import { DeleteCustomerInvoiceUseCase } from "../../../application";
export class DeleteCustomerInvoiceController extends ExpressController {
public constructor(
private readonly useCase: DeleteCustomerInvoiceUseCase
/* private readonly presenter: any */
) {
super();
// 🔐 Reutiliza guards de auth/tenant y prohíbe 'companyId' en query
this.useGuards(authGuard(), tenantGuard(), forbidQueryFieldGuard("companyId"));
}
async executeImpl() {
const tenantId = this.getTenantId()!; // garantizado por tenantGuard
const { id } = this.req.params;
const result = await this.useCase.execute({ id, tenantId });
return result.match(
(data) => this.ok(data),
2025-08-26 18:55:59 +00:00
(err) => this.handleError(err)
);
}
}