Uecko_ERP/modules/customers/src/api/controllers/delete-customer/delete-invoice.controller.ts

31 lines
843 B
TypeScript
Raw Normal View History

2025-08-11 17:49:52 +00:00
import { ExpressController, errorMapper } from "@erp/core/api";
import { DeleteCustomerUseCase } from "../../application";
export class DeleteCustomerController extends ExpressController {
public constructor(private readonly deleteCustomer: DeleteCustomerUseCase) {
super();
}
async executeImpl(): Promise<any> {
const { id } = this.req.params;
/*
const user = this.req.user; // asumimos middleware authenticateJWT inyecta user
if (!user || !user.companyId) {
this.unauthorized(res, "Unauthorized: user or company not found");
return;
}
*/
const result = await this.deleteCustomer.execute({ id });
if (result.isFailure) {
const apiError = errorMapper.toApiError(result.error);
return this.handleApiError(apiError);
}
return this.ok(result.data);
}
}