- Prefijo v2: MCH - TRACEABILITY-MASTER.yml creado - Listo para integracion como submodulo Workspace: v2.0.0 | SIMCO: v4.0.0
225 lines
11 KiB
JavaScript
225 lines
11 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.MarketplaceController = 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 marketplace_service_1 = require("./marketplace.service");
|
|
const create_supplier_order_dto_1 = require("./dto/create-supplier-order.dto");
|
|
const create_supplier_review_dto_1 = require("./dto/create-supplier-review.dto");
|
|
const supplier_order_entity_1 = require("./entities/supplier-order.entity");
|
|
let MarketplaceController = class MarketplaceController {
|
|
constructor(marketplaceService) {
|
|
this.marketplaceService = marketplaceService;
|
|
}
|
|
async findSuppliers(category, zipCode, search, limit) {
|
|
return this.marketplaceService.findSuppliers({
|
|
category,
|
|
zipCode,
|
|
search,
|
|
limit: limit ? Number(limit) : undefined,
|
|
});
|
|
}
|
|
async getSupplier(id) {
|
|
return this.marketplaceService.getSupplier(id);
|
|
}
|
|
async getSupplierProducts(id, category, search, inStock) {
|
|
return this.marketplaceService.getSupplierProducts(id, {
|
|
category,
|
|
search,
|
|
inStock,
|
|
});
|
|
}
|
|
async getSupplierReviews(id, limit, offset) {
|
|
return this.marketplaceService.getReviews(id, {
|
|
limit: limit ? Number(limit) : undefined,
|
|
offset: offset ? Number(offset) : undefined,
|
|
});
|
|
}
|
|
async createOrder(req, dto) {
|
|
return this.marketplaceService.createOrder(req.user.tenantId, dto);
|
|
}
|
|
async getOrders(req, status, supplierId, limit) {
|
|
return this.marketplaceService.getOrders(req.user.tenantId, {
|
|
status,
|
|
supplierId,
|
|
limit: limit ? Number(limit) : undefined,
|
|
});
|
|
}
|
|
async getOrder(id) {
|
|
return this.marketplaceService.getOrder(id);
|
|
}
|
|
async cancelOrder(req, id, body) {
|
|
return this.marketplaceService.cancelOrder(id, req.user.tenantId, body.reason);
|
|
}
|
|
async createReview(req, dto) {
|
|
return this.marketplaceService.createReview(req.user.tenantId, dto);
|
|
}
|
|
async getFavorites(req) {
|
|
return this.marketplaceService.getFavorites(req.user.tenantId);
|
|
}
|
|
async addFavorite(req, supplierId) {
|
|
await this.marketplaceService.addFavorite(req.user.tenantId, supplierId);
|
|
return { message: 'Agregado a favoritos' };
|
|
}
|
|
async removeFavorite(req, supplierId) {
|
|
await this.marketplaceService.removeFavorite(req.user.tenantId, supplierId);
|
|
return { message: 'Eliminado de favoritos' };
|
|
}
|
|
async getStats() {
|
|
return this.marketplaceService.getMarketplaceStats();
|
|
}
|
|
};
|
|
exports.MarketplaceController = MarketplaceController;
|
|
__decorate([
|
|
(0, common_1.Get)('suppliers'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Listar proveedores' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'category', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'zipCode', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'search', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
|
|
__param(0, (0, common_1.Query)('category')),
|
|
__param(1, (0, common_1.Query)('zipCode')),
|
|
__param(2, (0, common_1.Query)('search')),
|
|
__param(3, (0, common_1.Query)('limit')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String, String, Number]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "findSuppliers", null);
|
|
__decorate([
|
|
(0, common_1.Get)('suppliers/:id'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener detalle de proveedor' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getSupplier", null);
|
|
__decorate([
|
|
(0, common_1.Get)('suppliers/:id/products'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener productos de un proveedor' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'category', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'search', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'inStock', required: false, type: Boolean }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__param(1, (0, common_1.Query)('category')),
|
|
__param(2, (0, common_1.Query)('search')),
|
|
__param(3, (0, common_1.Query)('inStock')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String, String, Boolean]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getSupplierProducts", null);
|
|
__decorate([
|
|
(0, common_1.Get)('suppliers/:id/reviews'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener resenas de un proveedor' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
|
|
(0, swagger_1.ApiQuery)({ name: 'offset', required: false, type: Number }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__param(1, (0, common_1.Query)('limit')),
|
|
__param(2, (0, common_1.Query)('offset')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, Number, Number]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getSupplierReviews", null);
|
|
__decorate([
|
|
(0, common_1.Post)('orders'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Crear pedido a proveedor' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, create_supplier_order_dto_1.CreateSupplierOrderDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "createOrder", null);
|
|
__decorate([
|
|
(0, common_1.Get)('orders'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Listar mis pedidos' }),
|
|
(0, swagger_1.ApiQuery)({ name: 'status', required: false, enum: supplier_order_entity_1.SupplierOrderStatus }),
|
|
(0, swagger_1.ApiQuery)({ name: 'supplierId', required: false }),
|
|
(0, swagger_1.ApiQuery)({ name: 'limit', required: false, type: Number }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Query)('status')),
|
|
__param(2, (0, common_1.Query)('supplierId')),
|
|
__param(3, (0, common_1.Query)('limit')),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String, String, Number]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getOrders", null);
|
|
__decorate([
|
|
(0, common_1.Get)('orders/:id'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener detalle de pedido' }),
|
|
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getOrder", null);
|
|
__decorate([
|
|
(0, common_1.Put)('orders/:id/cancel'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Cancelar pedido' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
|
__param(2, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String, Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "cancelOrder", null);
|
|
__decorate([
|
|
(0, common_1.Post)('reviews'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Crear resena de proveedor' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, create_supplier_review_dto_1.CreateSupplierReviewDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "createReview", null);
|
|
__decorate([
|
|
(0, common_1.Get)('favorites'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener proveedores favoritos' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getFavorites", null);
|
|
__decorate([
|
|
(0, common_1.Post)('favorites/:supplierId'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Agregar proveedor a favoritos' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Param)('supplierId', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "addFavorite", null);
|
|
__decorate([
|
|
(0, common_1.Delete)('favorites/:supplierId'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Quitar proveedor de favoritos' }),
|
|
__param(0, (0, common_1.Request)()),
|
|
__param(1, (0, common_1.Param)('supplierId', common_1.ParseUUIDPipe)),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object, String]),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "removeFavorite", null);
|
|
__decorate([
|
|
(0, common_1.Get)('stats'),
|
|
(0, swagger_1.ApiOperation)({ summary: 'Obtener estadisticas del marketplace' }),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", []),
|
|
__metadata("design:returntype", Promise)
|
|
], MarketplaceController.prototype, "getStats", null);
|
|
exports.MarketplaceController = MarketplaceController = __decorate([
|
|
(0, swagger_1.ApiTags)('Marketplace'),
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
(0, common_1.Controller)('marketplace'),
|
|
__metadata("design:paramtypes", [marketplace_service_1.MarketplaceService])
|
|
], MarketplaceController);
|
|
//# sourceMappingURL=marketplace.controller.js.map
|