fpavon-ee-shared 1.0.57 → 1.0.58
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.
|
@@ -22,31 +22,31 @@ class ExpedienteElectronicoSqlRepository {
|
|
|
22
22
|
getExpedienteById(id) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else {
|
|
45
|
-
if (response.recordset.length == 0) {
|
|
46
|
-
throw new Error(`No existe la expediente con id=${id}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
25
|
+
const pool = yield (0, connection_sql_1.getConnectionForTransaction)();
|
|
26
|
+
const result = yield pool
|
|
27
|
+
.request()
|
|
28
|
+
.input("id", mssql_1.default.Int, parseInt(id))
|
|
29
|
+
.query(`
|
|
30
|
+
SELECT ee.*
|
|
31
|
+
FROM ExpedienteElectronico ee
|
|
32
|
+
WHERE ee.id = @id
|
|
33
|
+
`);
|
|
34
|
+
if (!result.recordset.length) {
|
|
35
|
+
throw new Error(`No existe el expediente con id=${id}`);
|
|
36
|
+
}
|
|
37
|
+
let expediente = result.recordset[0];
|
|
38
|
+
expediente.bitacora = JSON.parse(expediente.bitacora);
|
|
39
|
+
expediente.notas = JSON.parse(expediente.notas);
|
|
40
|
+
expediente.documentos = JSON.parse(expediente.documentos);
|
|
41
|
+
expediente.documentos.forEach((doc, index) => {
|
|
42
|
+
const documento = new documento_class_1.Documento(doc.uuid, doc.nombre, doc.descripcion, doc.size, { extras: doc.extras }, doc.firmado, doc.estadoWorkflow);
|
|
43
|
+
expediente.documentos[index] = documento;
|
|
49
44
|
});
|
|
45
|
+
expediente.extras = JSON.parse(expediente.extras);
|
|
46
|
+
expediente.usuarioResponsable = JSON.parse(expediente.usuarioResponsable);
|
|
47
|
+
expediente.estado = new estado_class_1.Estado(JSON.parse(expediente.estado));
|
|
48
|
+
Object.assign(expediente, expediente.extras);
|
|
49
|
+
return new expediente_electronico_class_1.ExpedienteElectronico(expediente);
|
|
50
50
|
}
|
|
51
51
|
catch (error) {
|
|
52
52
|
console.error("Error expedientesRepository.getExpedienteById=>", error);
|
package/expediente-electronico/infrastructure/repositories/expediente-electronico.sql.repository.ts
CHANGED
|
@@ -16,40 +16,47 @@ import sql from "mssql";
|
|
|
16
16
|
export class ExpedienteElectronicoSqlRepository implements IExpedienteElectronicoRepository {
|
|
17
17
|
async getExpedienteById(id: string) {
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
19
|
+
const pool = await getConnectionForTransaction();
|
|
20
|
+
const result = await pool
|
|
21
|
+
.request()
|
|
22
|
+
.input("id", sql.Int, parseInt(id))
|
|
23
|
+
.query(`
|
|
24
|
+
SELECT ee.*
|
|
25
|
+
FROM ExpedienteElectronico ee
|
|
26
|
+
WHERE ee.id = @id
|
|
27
|
+
`);
|
|
28
|
+
|
|
29
|
+
if (!result.recordset.length) {
|
|
30
|
+
throw new Error(`No existe el expediente con id=${id}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let expediente = result.recordset[0];
|
|
34
|
+
|
|
35
|
+
expediente.bitacora = JSON.parse(expediente.bitacora);
|
|
36
|
+
expediente.notas = JSON.parse(expediente.notas);
|
|
37
|
+
expediente.documentos = JSON.parse(expediente.documentos);
|
|
38
|
+
|
|
39
|
+
expediente.documentos.forEach((doc, index) => {
|
|
40
|
+
const documento = new Documento(
|
|
41
|
+
doc.uuid,
|
|
42
|
+
doc.nombre,
|
|
43
|
+
doc.descripcion,
|
|
44
|
+
doc.size,
|
|
45
|
+
{ extras: doc.extras },
|
|
46
|
+
doc.firmado,
|
|
47
|
+
doc.estadoWorkflow
|
|
48
|
+
);
|
|
49
|
+
expediente.documentos[index] = documento;
|
|
52
50
|
});
|
|
51
|
+
|
|
52
|
+
expediente.extras = JSON.parse(expediente.extras);
|
|
53
|
+
expediente.usuarioResponsable = JSON.parse(expediente.usuarioResponsable);
|
|
54
|
+
expediente.estado = new Estado(JSON.parse(expediente.estado));
|
|
55
|
+
|
|
56
|
+
Object.assign(expediente, expediente.extras);
|
|
57
|
+
|
|
58
|
+
return new ExpedienteElectronico(expediente);
|
|
59
|
+
|
|
53
60
|
} catch (error) {
|
|
54
61
|
console.error("Error expedientesRepository.getExpedienteById=>", error);
|
|
55
62
|
throw error;
|