UNPKG

prg-class

Version:

Clases genéricas utilizadas por microservicios Programamos SPA.

85 lines (84 loc) 3.42 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.QuerySPOne = void 0; const F = require("prg-function"); const _001_exec_sp_1 = require("./001-exec-sp"); class QuerySPOne extends _001_exec_sp_1.ExecSP { // protected mbAudit: boolean = false; constructor() { super(); this.msCustomErrMsg = ''; this.mbCustomRet = false; this.mbNonZeroPositiveIsOk = false; this.msSPName = ''; // Asignación de nombre de nombre de procedimiento almacenado. } fnQueryOne(aoParams) { return __awaiter(this, void 0, void 0, function* () { const loRet = yield this.fnSpExecute(aoParams, this.mbAudit); this.auditMe(this.mbAudit, 'fnQueryOne...loRet', loRet); if (loRet.error) { return loRet; } const loRetData = yield this.normalReturn(loRet.json); if (this.mbCustomRet === true) { return this.customReturn(loRetData.json); } return loRetData; }); } customReturn(aoData) { return __awaiter(this, void 0, void 0, function* () { if (!aoData || aoData.length <= 0 || aoData[0].length <= 0) { return F.fnRetOk(aoData); } const loData = { D000: aoData[0] }; // , for (let i = 1; i < 30; i++) { if (aoData.length >= i + 1) { const lsCero = i < 10 ? '00' : '0'; const lsFld = 'D' + lsCero + i; loData[lsFld] = aoData[i]; } } return F.fnRetOk(loData); }); } normalReturn(aoData) { return __awaiter(this, void 0, void 0, function* () { this.auditMe(this.mbAudit, 'normalReturn...aoData', aoData); if (!aoData || aoData.length <= 0 || aoData[0].length <= 0) { this.auditMe(this.mbAudit, 'normalReturn...no.aoData', ''); return F.fnRetOk(aoData); } const loData = { D000: aoData[0] }; // , for (let i = 1; i < 30; i++) { if (aoData.length >= i + 1) { const lsCero = i < 10 ? '00' : '0'; const lsFld = 'D' + lsCero + i; loData[lsFld] = aoData[i]; } } this.auditMe(this.mbAudit, 'normalReturn...loData', loData); return F.fnRetOk(loData); }); } getSPParams(aoParam) { const lsKey = F.trim(aoParam.Key); const loPrm = []; loPrm.push(lsKey); return loPrm; } } exports.QuerySPOne = QuerySPOne;