| Current Path : /home/deltalab/PMS/logistic-backend/dist/models/routes/ |
| Current File : //home/deltalab/PMS/logistic-backend/dist/models/routes/route.controller.js |
"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.RouteController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const route_schema_1 = require("./route.schema");
const route_service_1 = require("./route.service");
let RouteController = class RouteController {
constructor(routeService) {
this.routeService = routeService;
}
async createProduct(response, route) {
const newRoute = await this.routeService.create(route);
return response.status(common_1.HttpStatus.CREATED).json(newRoute);
}
async fetchAll(response, carrier, date) {
const routes = await this.routeService.readAll({ carrier, date });
return response.status(common_1.HttpStatus.OK).json(routes);
}
async findById(response, id) {
const route = await this.routeService.readById(id);
return response.status(common_1.HttpStatus.OK).json(route);
}
async update(response, id, route) {
const updatedRoute = await this.routeService.update(id, route);
return response.status(common_1.HttpStatus.OK).json(updatedRoute);
}
async delete(response, id) {
const deletedRoute = await this.routeService.delete(id);
return response.status(common_1.HttpStatus.OK).json(deletedRoute);
}
};
__decorate([
(0, common_1.Post)(),
openapi.ApiResponse({ status: 201, type: require("./route.schema").Route }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, route_schema_1.Route]),
__metadata("design:returntype", Promise)
], RouteController.prototype, "createProduct", null);
__decorate([
(0, common_1.Get)(),
openapi.ApiResponse({ status: 200, type: [require("./route.schema").Route] }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Query)('carrier')),
__param(2, (0, common_1.Query)('date')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String, Date]),
__metadata("design:returntype", Promise)
], RouteController.prototype, "fetchAll", null);
__decorate([
(0, common_1.Get)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./route.schema").Route }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", Promise)
], RouteController.prototype, "findById", null);
__decorate([
(0, common_1.Put)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./route.schema").Route }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Param)('id')),
__param(2, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, route_schema_1.Route]),
__metadata("design:returntype", Promise)
], RouteController.prototype, "update", null);
__decorate([
(0, common_1.Delete)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./route.schema").Route }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Param)('id')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", Promise)
], RouteController.prototype, "delete", null);
RouteController = __decorate([
(0, swagger_1.ApiTags)('Routes'),
(0, common_1.Controller)({ path: 'routes', version: '1' }),
__metadata("design:paramtypes", [route_service_1.RouteService])
], RouteController);
exports.RouteController = RouteController;
//# sourceMappingURL=route.controller.js.map