| Current Path : /home/deltalab/PMS/logistic-backend/dist/models/carriers/ |
| Current File : //home/deltalab/PMS/logistic-backend/dist/models/carriers/carrier.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.CarrierController = void 0;
const openapi = require("@nestjs/swagger");
const common_1 = require("@nestjs/common");
const swagger_1 = require("@nestjs/swagger");
const carrier_schema_1 = require("./carrier.schema");
const carrier_service_1 = require("./carrier.service");
let CarrierController = class CarrierController {
constructor(carrierService) {
this.carrierService = carrierService;
}
async createProduct(response, carrier) {
const newCarrier = await this.carrierService.create(carrier);
return response.status(common_1.HttpStatus.CREATED).json(newCarrier);
}
async fetchAll(response) {
const carriers = await this.carrierService.readAll();
return response.status(common_1.HttpStatus.OK).json(carriers);
}
async findById(response, id) {
const carrier = await this.carrierService.readById(id);
return response.status(common_1.HttpStatus.OK).json(carrier);
}
async update(response, id, carrier) {
const updatedCarrier = await this.carrierService.update(id, carrier);
return response.status(common_1.HttpStatus.OK).json(updatedCarrier);
}
async delete(response, id) {
const deletedCarrier = await this.carrierService.delete(id);
return response.status(common_1.HttpStatus.OK).json(deletedCarrier);
}
};
__decorate([
(0, common_1.Post)(),
openapi.ApiResponse({ status: 201, type: require("./carrier.schema").Carrier }),
__param(0, (0, common_1.Res)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, carrier_schema_1.Carrier]),
__metadata("design:returntype", Promise)
], CarrierController.prototype, "createProduct", null);
__decorate([
(0, common_1.Get)(),
openapi.ApiResponse({ status: 200, type: [require("./carrier.schema").Carrier] }),
__param(0, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], CarrierController.prototype, "fetchAll", null);
__decorate([
(0, common_1.Get)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./carrier.schema").Carrier }),
__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)
], CarrierController.prototype, "findById", null);
__decorate([
(0, common_1.Put)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./carrier.schema").Carrier }),
__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, carrier_schema_1.Carrier]),
__metadata("design:returntype", Promise)
], CarrierController.prototype, "update", null);
__decorate([
(0, common_1.Delete)('/:id'),
openapi.ApiResponse({ status: 200, type: require("./carrier.schema").Carrier }),
__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)
], CarrierController.prototype, "delete", null);
CarrierController = __decorate([
(0, swagger_1.ApiTags)('Carries'),
(0, common_1.Controller)({ path: 'carriers', version: '1' }),
__metadata("design:paramtypes", [carrier_service_1.CarrierService])
], CarrierController);
exports.CarrierController = CarrierController;
//# sourceMappingURL=carrier.controller.js.map