michangarrito/apps/backend/dist/modules/orders/orders.controller.js
rckrdmrd 48dea7a5d0 feat: Initial commit - michangarrito
Marketplace móvil para negocios locales mexicanos.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React Web)
- apps/mobile (Expo/React Native)
- apps/mcp-server (Claude MCP Server)
- apps/whatsapp-service (WhatsApp Business API)
- database/ (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:02 -06:00

202 lines
8.6 KiB
JavaScript

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrdersController = void 0;
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
const orders_service_1 = require("./orders.service");
const order_dto_1 = require("./dto/order.dto");
const order_entity_1 = require("./entities/order.entity");
let OrdersController = class OrdersController {
constructor(ordersService) {
this.ordersService = ordersService;
}
findAll(req, status) {
return this.ordersService.findAll(req.user.tenantId, status);
}
getActive(req) {
return this.ordersService.getActiveOrders(req.user.tenantId);
}
getToday(req) {
return this.ordersService.getTodayOrders(req.user.tenantId);
}
getStats(req) {
return this.ordersService.getOrderStats(req.user.tenantId);
}
findByNumber(req, orderNumber) {
return this.ordersService.findByOrderNumber(req.user.tenantId, orderNumber);
}
findOne(req, id) {
return this.ordersService.findOne(req.user.tenantId, id);
}
create(req, dto) {
return this.ordersService.create(req.user.tenantId, dto);
}
updateStatus(req, id, dto) {
return this.ordersService.updateStatus(req.user.tenantId, id, dto);
}
confirm(req, id) {
return this.ordersService.updateStatus(req.user.tenantId, id, {
status: order_entity_1.OrderStatus.CONFIRMED,
});
}
prepare(req, id) {
return this.ordersService.updateStatus(req.user.tenantId, id, {
status: order_entity_1.OrderStatus.PREPARING,
});
}
ready(req, id) {
return this.ordersService.updateStatus(req.user.tenantId, id, {
status: order_entity_1.OrderStatus.READY,
});
}
complete(req, id) {
return this.ordersService.updateStatus(req.user.tenantId, id, {
status: order_entity_1.OrderStatus.COMPLETED,
});
}
cancel(req, id, reason) {
return this.ordersService.updateStatus(req.user.tenantId, id, {
status: order_entity_1.OrderStatus.CANCELLED,
reason,
});
}
};
exports.OrdersController = OrdersController;
__decorate([
(0, common_1.Get)(),
(0, swagger_1.ApiOperation)({ summary: 'Listar pedidos' }),
(0, swagger_1.ApiQuery)({ name: 'status', enum: order_entity_1.OrderStatus, required: false }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Query)('status')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "findAll", null);
__decorate([
(0, common_1.Get)('active'),
(0, swagger_1.ApiOperation)({ summary: 'Pedidos activos (pendientes, preparando, listos)' }),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "getActive", null);
__decorate([
(0, common_1.Get)('today'),
(0, swagger_1.ApiOperation)({ summary: 'Pedidos de hoy' }),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "getToday", null);
__decorate([
(0, common_1.Get)('stats'),
(0, swagger_1.ApiOperation)({ summary: 'Estadísticas de pedidos' }),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "getStats", null);
__decorate([
(0, common_1.Get)('number/:orderNumber'),
(0, swagger_1.ApiOperation)({ summary: 'Buscar por número de pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('orderNumber')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "findByNumber", null);
__decorate([
(0, common_1.Get)(':id'),
(0, swagger_1.ApiOperation)({ summary: 'Obtener pedido por ID' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "findOne", null);
__decorate([
(0, common_1.Post)(),
(0, swagger_1.ApiOperation)({ summary: 'Crear nuevo pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, order_dto_1.CreateOrderDto]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "create", null);
__decorate([
(0, common_1.Patch)(':id/status'),
(0, swagger_1.ApiOperation)({ summary: 'Actualizar estado del pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__param(2, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String, order_dto_1.UpdateOrderStatusDto]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "updateStatus", null);
__decorate([
(0, common_1.Patch)(':id/confirm'),
(0, swagger_1.ApiOperation)({ summary: 'Confirmar pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "confirm", null);
__decorate([
(0, common_1.Patch)(':id/prepare'),
(0, swagger_1.ApiOperation)({ summary: 'Marcar como preparando' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "prepare", null);
__decorate([
(0, common_1.Patch)(':id/ready'),
(0, swagger_1.ApiOperation)({ summary: 'Marcar como listo' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "ready", null);
__decorate([
(0, common_1.Patch)(':id/complete'),
(0, swagger_1.ApiOperation)({ summary: 'Completar pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "complete", null);
__decorate([
(0, common_1.Patch)(':id/cancel'),
(0, swagger_1.ApiOperation)({ summary: 'Cancelar pedido' }),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Param)('id')),
__param(2, (0, common_1.Body)('reason')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String, String]),
__metadata("design:returntype", void 0)
], OrdersController.prototype, "cancel", null);
exports.OrdersController = OrdersController = __decorate([
(0, swagger_1.ApiTags)('orders'),
(0, swagger_1.ApiBearerAuth)(),
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
(0, common_1.Controller)('v1/orders'),
__metadata("design:paramtypes", [orders_service_1.OrdersService])
], OrdersController);
//# sourceMappingURL=orders.controller.js.map