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