utn-cli 2.1.18 → 2.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/backend.js +63 -40
- package/package.json +1 -1
- package/templates/backend/servicios/InformacionDelModulo.js +48 -168
- package/templates/backend/servicios/Nucleo/Miscelaneas.js +2433 -84
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Archivos.js +0 -329
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Autenticacion.js +0 -388
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/InicializacionDelModulo.js +0 -254
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Modulos.js +0 -261
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Notificaciones.js +0 -82
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Personas.js +0 -93
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/Reportes.js +0 -370
- package/templates/backend/servicios/Nucleo/MiscelaneasMixins/TareasProgramadas.js +0 -105
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
const { ejecutarConsultaSIGU } = require('../db.js');
|
|
2
|
-
const { envioDeCorreo } = require('../EnvioDeCorreos.js');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
|
|
6
|
-
versionDelNucleo() {
|
|
7
|
-
return "VERSION_DEL_NUCLEO" + " " + this.NombreCanonicoDelModulo;
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
generarEnlace(Modulo) {
|
|
11
|
-
return ((process.env.ENV || 'local') === 'production' ? 'https' : 'http')
|
|
12
|
-
+ '://' + Modulo
|
|
13
|
-
+ ((process.env.ENV || 'local') === 'production' ? '' : '-' + (process.env.ENV || 'local'))
|
|
14
|
-
+ ((process.env.ENV || 'local') === 'production' ? '.sigu.utn.ac.cr' : '-');
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
enlaceDelFrontend() {
|
|
18
|
-
return this.Enlace;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
getNombreDelRepositorioDelBackend() {
|
|
22
|
-
return this.NombreDelRepositorioDelBackend;
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
generarUUID() {
|
|
26
|
-
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11)
|
|
27
|
-
.replace(/[018]/g, c =>
|
|
28
|
-
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
async getUUID() {
|
|
33
|
-
const Identificador = await ejecutarConsultaSIGU("SELECT `Identificador` FROM `SIGU`.`SIGU_Repositorios` WHERE `Repositorio` = ?", [this.NombreDelRepositorioDelBackend]);
|
|
34
|
-
return Identificador[0]['Identificador'];
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
async perfilGeneralId() {
|
|
38
|
-
const PerfilGeneralId = await ejecutarConsultaSIGU("SELECT `PerfilGeneralId` FROM `SIGU`.`SIGU_PerfilesGenerales` WHERE `Perfil` = ?", [this.PerfilGeneral]);
|
|
39
|
-
return PerfilGeneralId[0]['PerfilGeneralId'];
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
async idDelFlujoDeAprobacion() {
|
|
43
|
-
const Resultado = await ejecutarConsultaSIGU("SELECT `FlujoDeAprobacionId` FROM `SIGU`.`SIGU_FlujosDeAprobacion` WHERE `NombreCanonico` = ?"
|
|
44
|
-
, [this.NombreCanonicoDelModulo]);
|
|
45
|
-
return Resultado[0]['FlujoDeAprobacionId'];
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
async permisosDelModuloV2(NombreCanonicoDelModulo) {
|
|
49
|
-
return await ejecutarConsultaSIGU("\
|
|
50
|
-
WITH RECURSIVE `Jerarquia` AS (\
|
|
51
|
-
SELECT\
|
|
52
|
-
`m`.`Padre`,\
|
|
53
|
-
`m`.`Nombre` AS `Modulo`,\
|
|
54
|
-
`p`.`PermisoId`,\
|
|
55
|
-
`p`.`Nombre` AS `Permiso`\
|
|
56
|
-
FROM `SIGU`.`SIGU_ModulosV2` `m`\
|
|
57
|
-
JOIN `SIGU`.`SIGU_PermisosV2` `p` ON `p`.`Modulo` = `m`.`Nombre`\
|
|
58
|
-
WHERE `m`.`Nombre` = ?\
|
|
59
|
-
UNION ALL\
|
|
60
|
-
SELECT \
|
|
61
|
-
`m`.`Padre`,\
|
|
62
|
-
`m`.`Nombre` AS `Modulo`,\
|
|
63
|
-
`p`.`PermisoId`,\
|
|
64
|
-
`p`.`Nombre` AS `Permiso`\
|
|
65
|
-
FROM `SIGU`.`SIGU_ModulosV2` `m`\
|
|
66
|
-
JOIN `SIGU`.`SIGU_PermisosV2` `p` ON `p`.`Modulo` = `m`.`Nombre`\
|
|
67
|
-
JOIN `Jerarquia` `j` ON `j`.`Padre` = `m`.`Nombre`\
|
|
68
|
-
)\
|
|
69
|
-
SELECT DISTINCT * FROM `Jerarquia`"
|
|
70
|
-
, [NombreCanonicoDelModulo]
|
|
71
|
-
);
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
async modulosV2() {
|
|
75
|
-
return await ejecutarConsultaSIGU("SELECT `Nombre`, `Padre`, `Descripcion`, `Detalle`, `Tipo`, `Icono`, `Color`, `Correo`, `Version`, `FechaDePublicacion`, `AcuerdoDeNivelDeServicio`, `DiccionarioDeDatos`, `Repositorios`, `EnlaceDelVideo`, `EnlaceDelManual`, `Estado` FROM `SIGU`.`SIGU_ModulosV2`");
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
async permisoIdV2() {
|
|
79
|
-
const Datos = await ejecutarConsultaSIGU("SELECT `PermisoId` FROM `SIGU`.`SIGU_PermisosV2` WHERE `Nombre` = ? AND `Modulo` = ?", [this.NombreDelPermisoV2, this.NombreCanonicoDelModulo]);
|
|
80
|
-
return Datos[0]['PermisoId'];
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
async permisoIdDelPadreV2() {
|
|
84
|
-
const Datos = await ejecutarConsultaSIGU("SELECT `PermisoId` FROM `SIGU`.`SIGU_PermisosV2` WHERE `Modulo` = ?"
|
|
85
|
-
, [this.MenuPadre]);
|
|
86
|
-
return Datos[0]['PermisoId'];
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
async rolPermisoIdDelModulo() {
|
|
90
|
-
this.RolId = await this.rolIdDelModulo();
|
|
91
|
-
this.PermisoId = await this.permisoIdDelModulo();
|
|
92
|
-
const RolPermisoId = await ejecutarConsultaSIGU("SELECT `RolPermisoId` FROM `SIGU`.`SIGU_RolesPermisos` WHERE `RolId` = ? AND `PermisoId` = ?"
|
|
93
|
-
, [this.RolId, this.PermisoId]);
|
|
94
|
-
return RolPermisoId[0]['RolPermisoId'];
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
async RegistrarPermisoExtra(Permiso, Descripcion) {
|
|
98
|
-
await ejecutarConsultaSIGU("SELECT IFNULL(MAX(`PermisoExtraId`), 0) + 1 INTO @`SiguientePermisoId` FROM `SIGU`.`SIGU_PermisosExtraV2`;\
|
|
99
|
-
INSERT INTO `SIGU`.`SIGU_PermisosExtraV2` VALUES\
|
|
100
|
-
(@`SiguientePermisoId`, ?, ?, ?, NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUser` = USER(), `Nombre` = ?, `Descripcion` = ?;"
|
|
101
|
-
, [Permiso, this.NombreCanonicoDelModulo, Descripcion, Permiso, Descripcion]);
|
|
102
|
-
|
|
103
|
-
if (this.UsuariosConAccesoInicial.length > 0) {
|
|
104
|
-
const PermisoExtraIdValor = await this.PermisoExtraId(Permiso);
|
|
105
|
-
this.UsuariosConAccesoInicial.forEach(async (dato) => {
|
|
106
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_PermisosExtraPersonasV2` VALUES (?,\
|
|
107
|
-
(SELECT `Identificador` FROM `SIGU`.`SIGU_Personas` WHERE `Identificacion` = ?), NOW(4), USER())\
|
|
108
|
-
ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4)"
|
|
109
|
-
, [PermisoExtraIdValor, dato]);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
async PermisoExtraId(Permiso) {
|
|
115
|
-
const PermisoExtraId = await ejecutarConsultaSIGU("SELECT `PermisoExtraId` FROM `SIGU`.`SIGU_PermisosExtraV2` \
|
|
116
|
-
WHERE `Nombre` = ? AND `Modulo` = ?"
|
|
117
|
-
, [Permiso, this.NombreCanonicoDelModulo]);
|
|
118
|
-
return PermisoExtraId[0]['PermisoExtraId'];
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
async RegistrarElServicio(Servicio, Tarjetas = null) {
|
|
122
|
-
const archivo = this._archivoFuenteActual;
|
|
123
|
-
try {
|
|
124
|
-
await ejecutarConsultaSIGU("REPLACE INTO `SIGU`.`SIGU_ModulosV2Secciones` (`Modulo`, `Descripcion`) VALUES (?, ?)"
|
|
125
|
-
, [this.NombreCanonicoDelModulo, Servicio]);
|
|
126
|
-
console.log(`Servicio ${Servicio} registrado correctamente`);
|
|
127
|
-
} catch (error) {
|
|
128
|
-
console.error(error.message);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (!Tarjetas) return;
|
|
132
|
-
|
|
133
|
-
const listaTarjetas = Array.isArray(Tarjetas) ? Tarjetas : [Tarjetas];
|
|
134
|
-
|
|
135
|
-
for (const tarjeta of listaTarjetas) {
|
|
136
|
-
try {
|
|
137
|
-
const titulo = tarjeta['Título'];
|
|
138
|
-
const existentes = await ejecutarConsultaSIGU(
|
|
139
|
-
`SELECT CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED) AS Posicion, JSON_VALUE(\`Datos\`, '$."Título"') AS Titulo, JSON_VALUE(\`Datos\`, '$."Descripción"') AS Descripcion FROM \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` WHERE \`Modulo\` = ? AND JSON_VALUE(\`Datos\`, '$."Título"') = ?`,
|
|
140
|
-
[this.NombreCanonicoDelModulo, titulo]
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
let datosFinales;
|
|
144
|
-
if (existentes.length > 0) {
|
|
145
|
-
datosFinales = { ...tarjeta, 'Posición': existentes[0].Posicion, 'Título': existentes[0].Titulo, 'Descripción': existentes[0].Descripcion, 'Archivo': archivo };
|
|
146
|
-
await ejecutarConsultaSIGU(
|
|
147
|
-
`UPDATE \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` SET \`Datos\` = ?, \`LastUser\` = 'Sistema' WHERE \`Modulo\` = ? AND JSON_VALUE(\`Datos\`, '$."Título"') = ?`,
|
|
148
|
-
[JSON.stringify(datosFinales), this.NombreCanonicoDelModulo, titulo]
|
|
149
|
-
);
|
|
150
|
-
} else {
|
|
151
|
-
let posicion = tarjeta['Posición'];
|
|
152
|
-
if (posicion === undefined) {
|
|
153
|
-
const [{ NuevaPosicion }] = await ejecutarConsultaSIGU(
|
|
154
|
-
`SELECT COALESCE(MAX(CAST(JSON_VALUE(\`Datos\`, '$."Posición"') AS UNSIGNED)), 0) + 10 AS NuevaPosicion FROM \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` WHERE \`Modulo\` = ?`,
|
|
155
|
-
[this.NombreCanonicoDelModulo]
|
|
156
|
-
);
|
|
157
|
-
posicion = NuevaPosicion;
|
|
158
|
-
}
|
|
159
|
-
datosFinales = { ...tarjeta, 'Posición': posicion, 'Archivo': archivo };
|
|
160
|
-
await ejecutarConsultaSIGU(
|
|
161
|
-
`INSERT INTO \`SIGU\`.\`SIGU_ModulosV2Tarjetas\` (\`Modulo\`, \`Datos\`, \`LastUser\`) VALUES (?, ?, 'Sistema')`,
|
|
162
|
-
[this.NombreCanonicoDelModulo, JSON.stringify(datosFinales)]
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
console.log(`Tarjeta "${titulo}" registrada correctamente`);
|
|
166
|
-
} catch (error) {
|
|
167
|
-
console.error(`Error al registrar tarjeta "${tarjeta['Título']}":`, error.message);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
async registroDelModuloEnSIGUV2() {
|
|
173
|
-
const Version = this.Version + "$$" + this.versionDelNucleo().split(' ')[0];
|
|
174
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_ModulosV2` VALUES\
|
|
175
|
-
(?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(4), ?, 'DiccionarioDeDatos'\
|
|
176
|
-
, ?, '-', '-', 'Activo', NOW(4), USER()) ON DUPLICATE KEY UPDATE `Version` = ?, `Repositorios` = ?"
|
|
177
|
-
, [this.NombreCanonicoDelModulo, this.MenuPadre, this.DescripcionDelModulo, this.DetalleDelModulo
|
|
178
|
-
, this.TipoDeCard, this.IconoDelModulo, this.ColorDelModulo, this.CorreoParaReportes, Version, this.versionDelNucleo().split(' ')[0], this.Repositorios
|
|
179
|
-
, Version, this.Repositorios]);
|
|
180
|
-
await ejecutarConsultaSIGU("SELECT IFNULL(MAX(`PermisoId`), 0) + 1 INTO @`SiguientePermisoId` FROM `SIGU`.`SIGU_PermisosV2`;\
|
|
181
|
-
INSERT INTO `SIGU`.`SIGU_PermisosV2` VALUES\
|
|
182
|
-
(@`SiguientePermisoId`, ?, ?, ?, NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUser` = USER(), `Nombre` = ?, `Descripcion` = ?;"
|
|
183
|
-
, [this.NombreDelPermisoV2, this.NombreCanonicoDelModulo, this.DescripcionDelPermiso, this.NombreDelPermisoV2, this.DescripcionDelPermiso]);
|
|
184
|
-
|
|
185
|
-
await ejecutarConsultaSIGU("SELECT COALESCE(MAX(`FlujoDeAprobacionId`), 0) + 1 INTO @`Consecutivo` FROM `SIGU`.`SIGU_FlujosDeAprobacion`;\
|
|
186
|
-
INSERT INTO `SIGU`.`SIGU_FlujosDeAprobacion` VALUES (@`Consecutivo`, ?, CONCAT('Flujo de aprobación predeterminado para:', ' ', ?), TRUE, NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4);"
|
|
187
|
-
, [this.NombreCanonicoDelModulo, this.NombreCanonicoDelModulo]);
|
|
188
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_FlujosDeAprobacionPasos` VALUES (\
|
|
189
|
-
(SELECT `FlujoDeAprobacionId` FROM `SIGU`.`SIGU_FlujosDeAprobacion` WHERE `NombreCanonico` = ?)\
|
|
190
|
-
, 0, 'Sin aprobaciones realizadas', (SELECT `Identificador` FROM `SIGU`.`SIGU_Personas` WHERE `Identificacion` = '111050570'), 0, NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4)"
|
|
191
|
-
, [this.NombreCanonicoDelModulo]);
|
|
192
|
-
|
|
193
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_PermisosPersonasV2` VALUES (?,\
|
|
194
|
-
(SELECT `Identificador` FROM `SIGU`.`SIGU_Personas` WHERE `Identificacion` = '111050570'), NOW(4), USER()) ON DUPLICATE KEY UPDATE `LastUser` = USER()"
|
|
195
|
-
, [await this.permisoIdV2()]);
|
|
196
|
-
|
|
197
|
-
if (this.UsuariosConAccesoInicial.length > 0) {
|
|
198
|
-
const permisoId = await this.permisoIdV2();
|
|
199
|
-
const permisoIdDelPadre = await this.permisoIdDelPadreV2();
|
|
200
|
-
this.UsuariosConAccesoInicial.forEach(async (dato) => {
|
|
201
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_PermisosPersonasV2` VALUES (?,\
|
|
202
|
-
(SELECT `Identificador` FROM `SIGU`.`SIGU_Personas` WHERE `Identificacion` = ?), NOW(4), USER())\
|
|
203
|
-
ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4)"
|
|
204
|
-
, [permisoIdDelPadre, dato]);
|
|
205
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_PermisosPersonasV2` VALUES (?,\
|
|
206
|
-
(SELECT `Identificador` FROM `SIGU`.`SIGU_Personas` WHERE `Identificacion` = ?), NOW(4), USER())\
|
|
207
|
-
ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4)"
|
|
208
|
-
, [permisoId, dato]);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const uuidTemporal = await ejecutarConsultaSIGU("SELECT UUID() AS `UUID`");
|
|
213
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_Repositorios` VALUES (?, ?) ON DUPLICATE KEY UPDATE `Identificador` = ?"
|
|
214
|
-
, [this.NombreDelRepositorioDelFrontend, uuidTemporal[0]['UUID'], uuidTemporal[0]['UUID']]);
|
|
215
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_RepositoriosAccesos` VALUES (?, ?)\
|
|
216
|
-
ON DUPLICATE KEY UPDATE `RepositorioDestino` = ?,`RepositorioOrigen` = ?"
|
|
217
|
-
, [this.NombreDelRepositorioDelBackend, this.NombreDelRepositorioDelFrontend, this.NombreDelRepositorioDelBackend, this.NombreDelRepositorioDelFrontend]);
|
|
218
|
-
|
|
219
|
-
console.log(new Date());
|
|
220
|
-
console.log(`Módulo registrado correctamente en SIGU. Módulo: ${this.NombreCanonicoDelModulo}`);
|
|
221
|
-
console.log(`Identificador del flujo de aprobación: ${await this.idDelFlujoDeAprobacion()}`);
|
|
222
|
-
console.log(`Enlace del módulo: ${this.Enlace}`);
|
|
223
|
-
console.log(`Permisos: ${JSON.stringify(await this.permisosDelModuloV2(this.NombreCanonicoDelModulo))}`);
|
|
224
|
-
this.creacionDeldirectorioParaElAlmacenamientoDeArchivos();
|
|
225
|
-
console.log(`Versión del núcleo: ${this.versionDelNucleo()}`);
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
async registroDelModuloEnSIGU() {
|
|
229
|
-
const InformacionDelModulo = require('../InformacionDelModulo.js');
|
|
230
|
-
await InformacionDelModulo.initialize();
|
|
231
|
-
this._sincronizarConInformacionDelModulo();
|
|
232
|
-
|
|
233
|
-
this.Enlace = this.generarEnlace(this.NombreDelRepositorioDelFrontend);
|
|
234
|
-
this.EnlaceDePortal = this.generarEnlace('portalv2-frontend');
|
|
235
|
-
this.EnlaceDePerfil = this.generarEnlace('perfilv2-frontend');
|
|
236
|
-
this.EnlaceDeAcceso = this.generarEnlace('accesov2-frontend');
|
|
237
|
-
|
|
238
|
-
const uuidTemporal = await ejecutarConsultaSIGU("SELECT UUID() AS `UUID`");
|
|
239
|
-
this.UUID = uuidTemporal[0]['UUID'];
|
|
240
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_Repositorios` VALUES (?, ?) ON DUPLICATE KEY UPDATE `Identificador` = ?"
|
|
241
|
-
, [this.NombreDelRepositorioDelBackend, this.UUID, this.UUID]);
|
|
242
|
-
process.env.UUID = this.UUID;
|
|
243
|
-
if (this.BackEndsQueConsumeEsteModulo.length > 0) {
|
|
244
|
-
this.BackEndsQueConsumeEsteModulo.forEach(async (dato) => {
|
|
245
|
-
await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_RepositoriosAccesos` VALUES (?, ?)\
|
|
246
|
-
ON DUPLICATE KEY UPDATE `RepositorioDestino` = ?,`RepositorioOrigen` = ?"
|
|
247
|
-
, [dato, this.NombreDelRepositorioDelBackend, dato, this.NombreDelRepositorioDelBackend]);
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
process.env.SERVIDORSMTP = await this.servidorSMTP();
|
|
252
|
-
process.env.USUARIOSMTP = await this.usuarioSMTP();
|
|
253
|
-
process.env.PUERTOSMTP = await this.puertoSMTP();
|
|
254
|
-
process.env.CLAVESMTP = await this.claveSMTP();
|
|
255
|
-
process.env.DESTINATARIODEINFORMESDEERROR = await this.destinatarioDeInformesDeError();
|
|
256
|
-
process.env.NOMBRECANONICODELMODULO = this.NombreCanonicoDelModulo;
|
|
257
|
-
|
|
258
|
-
await this.registroDelModuloEnSIGUV2();
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const { ejecutarConsultaSIGU } = require('../db.js');
|
|
2
|
-
const { envioDeCorreo } = require('../EnvioDeCorreos.js');
|
|
3
|
-
const ManejadorDeErrores = require('../ManejadorDeErrores.js');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
|
|
7
|
-
async destinatarioDeInformesDeError() {
|
|
8
|
-
const resultado = await ejecutarConsultaSIGU("SELECT `Valor` FROM `SIGU`.`SIGU_VariablesDeSistema` WHERE `Nombre` = 'DestinatarioDeInformesDeError'");
|
|
9
|
-
return resultado.length > 0 ? resultado[0]['Valor'] : '';
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
async claveSMTP() {
|
|
13
|
-
const resultado = await ejecutarConsultaSIGU("SELECT `Valor` FROM `SIGU`.`SIGU_VariablesDeSistema` WHERE `Nombre` = 'ClaveSMTP'");
|
|
14
|
-
return resultado.length > 0 ? resultado[0]['Valor'] : '';
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
async puertoSMTP() {
|
|
18
|
-
const resultado = await ejecutarConsultaSIGU("SELECT `Valor` FROM `SIGU`.`SIGU_VariablesDeSistema` WHERE `Nombre` = 'PuertoSMTP'");
|
|
19
|
-
return resultado.length > 0 ? resultado[0]['Valor'] : '';
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
async usuarioSMTP() {
|
|
23
|
-
const resultado = await ejecutarConsultaSIGU("SELECT `Valor` FROM `SIGU`.`SIGU_VariablesDeSistema` WHERE `Nombre` = 'UsuarioSMTP'");
|
|
24
|
-
return resultado.length > 0 ? resultado[0]['Valor'] : '';
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
async servidorSMTP() {
|
|
28
|
-
const resultado = await ejecutarConsultaSIGU("SELECT `Valor` FROM `SIGU`.`SIGU_VariablesDeSistema` WHERE `Nombre` = 'ServidorSMTP'");
|
|
29
|
-
return resultado.length > 0 ? resultado[0]['Valor'] : '';
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
async crearNotificacion(IdentificadorDelUsuario, IdentificadorDelDestinatario, Mensaje) {
|
|
33
|
-
return await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_NotificacionesV2` VALUES (?, ?, 'Sin leer', NOW(4), NOW(4), ?)", [IdentificadorDelDestinatario, Mensaje, IdentificadorDelUsuario]);
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
async actualizarNotificacion(Token, FechaYHoraDeCreacion) {
|
|
37
|
-
let Resultado = undefined;
|
|
38
|
-
try {
|
|
39
|
-
Resultado = await this.obtenerDatosDelUsuario(Token);
|
|
40
|
-
if (!Resultado) throw new ManejadorDeErrores(ManejadorDeErrores.mensajeDeErrorVerificacionDeToken(), ManejadorDeErrores.obtenerNumeroDeLinea());
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.log(error);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
return await ejecutarConsultaSIGU("UPDATE `SIGU`.`SIGU_NotificacionesV2` SET `Estado` = 'Leída' WHERE `Identificador` = ? AND `FechaYHoraDeCreacion` = ?", [Resultado.Identificador, FechaYHoraDeCreacion]);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
async obtenerNotificaciones(Token) {
|
|
49
|
-
let Resultado = undefined;
|
|
50
|
-
try {
|
|
51
|
-
Resultado = await this.obtenerDatosDelUsuario(Token);
|
|
52
|
-
if (!Resultado) throw new ManejadorDeErrores(ManejadorDeErrores.mensajeDeErrorVerificacionDeToken(), ManejadorDeErrores.obtenerNumeroDeLinea());
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.log(error);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
return await ejecutarConsultaSIGU("SELECT `Notificacion` AS `valor`, CONCAT(`FechaYHoraDeCreacion`) AS `llave`, false AS `tachado` FROM `SIGU`.`SIGU_NotificacionesV2` WHERE `Identificador` = ? AND `Estado` = 'Sin leer' ORDER BY `FechaYHoraDeCreacion` DESC LIMIT 10", [Resultado.Identificador]);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
async reporteDeIncidencia(Solicitud, Datos) {
|
|
61
|
-
const DatosDelArchivo = await this.cargarArchivo(Solicitud, Datos);
|
|
62
|
-
await envioDeCorreo('msavatar@utn.ac.cr', "Reporte de incidencia",
|
|
63
|
-
"<p><b>Sistema: </b>" + this.NombreCanonicoDelModulo + "</p><br />"
|
|
64
|
-
+ "<p><b>Asunto: </b>Reporte de incidencia</p><br />"
|
|
65
|
-
+ "<p><b>Detalle de la incidencia: </b>" + Datos.detalle + "</p><br />"
|
|
66
|
-
+ "<p><b>Resultado esperado: </b>" + Datos.resultado + "</p><br />"
|
|
67
|
-
+ "<p><b>Información de contacto: </b>" + Datos.concato + "</p><br />"
|
|
68
|
-
+ "<p><b>Información del usuario: </b>" + await this.obtenerDatosDelUsuario(Solicitud.headers.authorization) + "</p><br />"
|
|
69
|
-
, [DatosDelArchivo.rutaDeArchivo]);
|
|
70
|
-
return;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
async reporteDeSugerencia(Solicitud, Datos) {
|
|
74
|
-
await envioDeCorreo('msavatar@utn.ac.cr', "Reporte de sugerencia",
|
|
75
|
-
"<p><b>Sistema: </b>" + this.NombreCanonicoDelModulo + "</p><br />"
|
|
76
|
-
+ "<p><b>Asunto: </b>Reporte de sugerencia</p><br />"
|
|
77
|
-
+ "<p><b>Detalle de la sugerencia: </b>" + Datos.detalle + "</p><br />"
|
|
78
|
-
+ "<p><b>Información del usuario: </b>" + await this.obtenerDatosDelUsuario(Solicitud.headers.authorization) + "</p><br />");
|
|
79
|
-
return;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
const { ejecutarConsultaSIGU } = require('../db.js');
|
|
2
|
-
const ManejadorDeErrores = require('../ManejadorDeErrores.js');
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
|
|
6
|
-
async ListadoDePaisesParaCrearCuenta() {
|
|
7
|
-
const Resultado = await ejecutarConsultaSIGU("SELECT REPLACE(MID(`COLUMN_TYPE`, 6, CHAR_LENGTH(`COLUMN_TYPE`) - 6), \"'\", '') AS `Datos` FROM `information_schema`.`COLUMNS`\
|
|
8
|
-
WHERE `TABLE_SCHEMA` = 'SIGU' AND `TABLE_NAME` = 'SIGU_Personas' AND `COLUMN_NAME` = 'Pais'");
|
|
9
|
-
return Resultado[0]['Datos'].split(',').sort();
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
async obtenerPersonasFuncionarias() {
|
|
13
|
-
return await ejecutarConsultaSIGU("SELECT `Identificador`, `Identificacion`, `Nombre`, `PrimerApellido`,\
|
|
14
|
-
`SegundoApellido` FROM `SIGU`.`SIGU_Personas` WHERE `Identificador` IN\
|
|
15
|
-
(SELECT `Identificador` FROM `SIGU`.`EstructuraOrganizacional_Instancias`) ORDER BY `Nombre`, `PrimerApellido`,\
|
|
16
|
-
`SegundoApellido`");
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
async obtenerDatosDeLaPersona(Token) {
|
|
20
|
-
let Resultado = undefined;
|
|
21
|
-
try {
|
|
22
|
-
Resultado = await this.obtenerDatosDelUsuario(Token);
|
|
23
|
-
if (!Resultado) throw new ManejadorDeErrores(ManejadorDeErrores.mensajeDeErrorVerificacionDeToken(), ManejadorDeErrores.obtenerNumeroDeLinea());
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.log(error);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
return await ejecutarConsultaSIGU("SELECT `a`.`Identificador`, `a`.`Identificacion`\
|
|
29
|
-
, `a`.`Nombre`, `a`.`PrimerApellido`, `a`.`SegundoApellido`\
|
|
30
|
-
, (SELECT GROUP_CONCAT(`b`.`CuentaIBAN`) FROM `SIGU`.`SIGU_CuentasBancariasPersonas` `b` WHERE `b`.`Estado` = TRUE AND `a`.`Identificador` = `b`.`Identificador`) AS `CuentasIBAN`\
|
|
31
|
-
FROM `SIGU`.`SIGU_Personas` `a` WHERE `a`.`Identificador` = ?"
|
|
32
|
-
, [Resultado.Identificador]);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
async obtenerDatosDeLaPersonaPorIdentificacion(Identificacion) {
|
|
36
|
-
return await ejecutarConsultaSIGU("SELECT `a`.`Identificador`, `a`.`Identificacion`\
|
|
37
|
-
, `a`.`Nombre`, `a`.`PrimerApellido`, `a`.`SegundoApellido`\
|
|
38
|
-
, (SELECT GROUP_CONCAT(`b`.`CuentaIBAN`) FROM `SIGU`.`SIGU_CuentasBancariasPersonas` `b` WHERE `b`.`Estado` = TRUE AND `a`.`Identificador` = `b`.`Identificador`) AS `CuentasIBAN`\
|
|
39
|
-
FROM `SIGU`.`SIGU_Personas` `a` WHERE `a`.`Identificacion` = ?"
|
|
40
|
-
, [Identificacion]);
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
async DatosPersonalesDeUnaPersona(Identificador) {
|
|
44
|
-
const Resultado = {};
|
|
45
|
-
const DatosDeLaPersona = await ejecutarConsultaSIGU("SELECT `Identificacion`, `Nombre`, `PrimerApellido`,\
|
|
46
|
-
`SegundoApellido`, (SELECT `CorreoElectronico` FROM `SIGU`.`SIGU_CorreosPersona` WHERE `Identificador` = ? AND `Principal` = TRUE) AS `CorreoElectronicoPrincipal`\
|
|
47
|
-
FROM `SIGU`.`SIGU_Personas` WHERE `Identificador` = ?", [Identificador, Identificador]);
|
|
48
|
-
Resultado.Identificador = Identificador;
|
|
49
|
-
Resultado.Identificacion = DatosDeLaPersona[0]['Identificacion'];
|
|
50
|
-
Resultado.Nombre = DatosDeLaPersona[0]['Nombre'];
|
|
51
|
-
Resultado.PrimerApellido = DatosDeLaPersona[0]['PrimerApellido'];
|
|
52
|
-
Resultado.SegundoApellido = DatosDeLaPersona[0]['SegundoApellido'];
|
|
53
|
-
Resultado.CorreoElectronicoPrincipal = DatosDeLaPersona[0]['CorreoElectronicoPrincipal'];
|
|
54
|
-
return Resultado;
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
async obtenerEstudiantes() {
|
|
58
|
-
return await ejecutarConsultaSIGU("SELECT `Identificador`, `Identificacion`, `Nombre`, `PrimerApellido`,\
|
|
59
|
-
`SegundoApellido` FROM `SIGU`.`SIGU_Personas` WHERE `Identificador` IN\
|
|
60
|
-
(SELECT `Identificador` FROM `SIGU`.`SIGU_RolesPersonas` WHERE `PerfilGeneralId` = 1)");
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
async obtenerBeneficios() {
|
|
64
|
-
return await ejecutarConsultaSIGU("SELECT `BeneficioId`, `Beneficio`, `Estado` FROM `SIGU`.`SIGU_Beneficios`");
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
async obtenerIdentificacion(Identificador) {
|
|
68
|
-
return await ejecutarConsultaSIGU("SELECT `Identificacion` FROM `SIGU`.`SIGU_Personas` WHERE `Identificador` = ?", [Identificador]);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
async obtenerPeriodos() {
|
|
72
|
-
return await ejecutarConsultaSIGU("SELECT `PeriodoId`, `CodigoPeriodo`, `Anio`, `Periodo`, `FechaInicio`, `FechaFinal`, `Tipo`, `Estado` FROM `SIGU`.`SIGU_Periodos` ORDER BY `Anio` DESC, `CodigoPeriodo` DESC");
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
async obtenerAnios() {
|
|
76
|
-
return await ejecutarConsultaSIGU("SELECT DISTINCT `Anio` FROM `SIGU`.`SIGU_Periodos`");
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
async obtenerSedes() {
|
|
80
|
-
return await ejecutarConsultaSIGU("SELECT `SedesId`, `CodigoAvatar`, `Descripcion`, `Siglas` FROM `SIGU`.`SIGU_Sedes` ORDER BY `Descripcion`");
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
async obtenerRecintos() {
|
|
84
|
-
return await ejecutarConsultaSIGU("SELECT `a`.`RecintoId`, CONCAT(`b`.`Descripcion`, '/', `a`.`Recinto`) AS `Recinto` FROM `SIGU`.`SIGU_Recintos` `a` LEFT JOIN `SIGU`.`SIGU_Sedes` `b` ON (`a`.`SedeId` = `b`.`SedesId`) ORDER BY `Recinto`");
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
almacenarCuentaIBAN(Cuerpo) {
|
|
88
|
-
return ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_CuentasBancariasPersonas` VALUES (NULL, ?, ?, TRUE, NOW(4), ?)\
|
|
89
|
-
ON DUPLICATE KEY UPDATE `LastUpdate` = NOW(4), `LastUser` = ?"
|
|
90
|
-
, [Cuerpo.Identificador, Cuerpo.IBAN, Cuerpo.LastUser, Cuerpo.LastUser]);
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
};
|