Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
node-rest-api-mcafee
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cristian Mauricio Diaz Canales
node-rest-api-mcafee
Commits
0ff928fa
Commit
0ff928fa
authored
Oct 22, 2020
by
Cristian Mauricio Diaz Canales
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mejoras sistema
parent
aa150142
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
217 additions
and
190 deletions
+217
-190
index.js
index.js
+0
-1
routes/campanias.js
routes/campanias.js
+217
-189
No files found.
index.js
View file @
0ff928fa
...
@@ -9,7 +9,6 @@ require('events').EventEmitter.prototype._maxListeners = 100;
...
@@ -9,7 +9,6 @@ require('events').EventEmitter.prototype._maxListeners = 100;
**/
**/
console
.
log
(
`Aplicacion :
${
config
.
get
(
"
name
"
)}
`
);
console
.
log
(
`Aplicacion :
${
config
.
get
(
"
name
"
)}
`
);
/*
/*
* Solo en ambientes de desarrollo locales se coloca el puerto directamente al iniciar la aplicacion
* Solo en ambientes de desarrollo locales se coloca el puerto directamente al iniciar la aplicacion
* en servidores, se debe obtener del objeto global "process"
* en servidores, se debe obtener del objeto global "process"
...
...
routes/campanias.js
View file @
0ff928fa
const
express
=
require
(
'
express
'
);
const
express
=
require
(
"
express
"
);
const
router
=
express
.
Router
();
const
router
=
express
.
Router
();
const
config
=
require
(
'
config
'
);
const
config
=
require
(
"
config
"
);
const
dbConn
=
require
(
'
../middleware/database
'
);
const
dbConn
=
require
(
"
../middleware/database
"
);
const
szerCampaniaValidator
=
require
(
"
../middleware/validation
"
);
const
szerCampaniaValidator
=
require
(
"
../middleware/validation
"
);
const
log
=
require
(
'
../middleware/logger
'
);
const
jsonResponse
=
{};
const
jsonResponse
=
{};
dbConn
.
getConnection
((
err
,
connection
)
=>
{
dbConn
.
getConnection
((
err
,
connection
)
=>
{
if
(
err
)
{
if
(
err
)
{
log
.
logger
.
error
(
`Error con la conexion a la base de datos :
${
err
}
`
);
log
.
logger
.
error
(
`Error con la conexion a la base de datos :
${
err
}
`
);
throw
err
;
throw
err
;
}
else
console
.
log
(
"
Conectado!...
"
)
;
}
else
console
.
log
(
"
Conectado!...
"
);
});
});
router
.
post
(
"
/obtener/contenido
"
,
(
req
,
res
)
=>
{
const
validateCampania
=
new
szerCampaniaValidator
();
router
.
post
(
'
/obtener/contenido
'
,
(
req
,
res
)
=>
{
//Si falta el parametro uid, error 400
const
validateCampania
=
new
szerCampaniaValidator
();
var
{
error
}
=
validateCampania
.
validate
(
req
.
body
);
//Si falta el parametro uid, error 400
if
(
error
)
{
var
{
error
}
=
validateCampania
.
validate
(
req
.
body
);
res
if
(
error
)
{
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.BAD_REQUEST
"
))
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.BAD_REQUEST
"
)).
json
({
"
error
"
:
error
.
details
[
0
].
message
});
.
json
({
error
:
error
.
details
[
0
].
message
});
return
;
return
;
}
}
//Seteo de UID ingresado en la peticion
let
{
uid
}
=
req
.
body
;
//Seteo de entorno mediante userAgent
let
isMobile
=
req
.
useragent
.
isMobile
;
processHtml
(
res
,
uid
,
isMobile
);
});
//Seteo de UID ingresado en la peticion
let
{
uid
}
=
req
.
body
;
//Seteo de entorno mediante userAgent
let
isMobile
=
req
.
useragent
.
isMobile
;
processHtml
(
res
,
uid
,
isMobile
);
});
async
function
processHtml
(
res
,
uid
,
isMobile
)
{
async
function
processHtml
(
res
,
uid
,
isMobile
)
{
//Buscar UID , si no esta es error 404
//Buscar UID , si no esta es error 404
//console.log("obteniendo campaña asociada...");
//console.log("obteniendo campaña asociada...");
const
campania
=
await
getCampaniaById
([
uid
]);
try
{
if
(
!
campania
||
campania
.
length
==
0
)
{
const
campania
=
await
getCampaniaById
([
uid
]);
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.NOT_FOUND
"
)).
json
({
"
error
"
:
`El uid
${
uid
}
no esta asociado a ninguna campaña.`
});
if
(
!
campania
||
campania
.
length
==
0
)
{
return
;
res
}
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.NOT_FOUND
"
))
.
json
({
error
:
`El uid
${
uid
}
no esta asociado a ninguna campaña.`
});
return
;
}
//console.log(campania[0].cam_id);
//console.log(campania[0].cam_id);
const
template
=
await
getTemplateById
([
campania
[
0
].
tem_id
]);
const
template
=
await
getTemplateById
([
campania
[
0
].
tem_id
]);
if
(
!
template
||
template
.
length
==
0
)
{
if
(
!
template
||
template
.
length
==
0
)
{
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.NOT_FOUND
"
)).
json
({
"
error
"
:
`La campaña uid
${
uid
}
no tiene asociado ninguna plantilla de diseño.`
});
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.NOT_FOUND
"
)).
json
({
return
;
error
:
`La campaña uid
${
uid
}
no tiene asociado ninguna plantilla de diseño.`
,
});
return
;
}
//console.log(template[0].tem_id);
//Seteo de la respuesta json
jsonResponse
.
templateCss
=
template
[
0
].
tem_css
;
jsonResponse
.
codeAdWords
=
campania
[
0
].
cam_adwords
;
jsonResponse
.
codeFacebookPixel
=
campania
[
0
].
cam_pixel_facebook
;
jsonResponse
.
contenidoHead
=
await
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.HEAD
"
),
isMobile
);
jsonResponse
.
contenidoBody
=
await
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.BODY
"
),
isMobile
);
jsonResponse
.
contenidoFooter
=
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.FOOTER
"
),
isMobile
);
jsonResponse
.
terminosCondiciones
=
generateHtmlCondiciones
(
campania
);
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.OK
"
)).
send
(
jsonResponse
);
}
catch
(
err
)
{
log
.
logger
.
error
(
`Error :
${
err
.
message
}
`
);
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.ERROR
"
))
.
json
({
error
:
`Ha ocurrido un error :
${
err
.
message
}
`
});
}
}
//console.log(template[0].tem_id);
//Seteo de la respuesta json
jsonResponse
.
templateCss
=
template
[
0
].
tem_css
;
jsonResponse
.
codeAdWords
=
campania
[
0
].
cam_adwords
;
jsonResponse
.
codeFacebookPixel
=
campania
[
0
].
cam_pixel_facebook
;
jsonResponse
.
contenidoHead
=
await
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.HEAD
"
),
isMobile
);
jsonResponse
.
contenidoBody
=
await
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.BODY
"
),
isMobile
);
jsonResponse
.
contenidoFooter
=
generateHtmlSection
(
campania
,
config
.
get
(
"
constants.HTML_SECTIONS.FOOTER
"
),
isMobile
);
jsonResponse
.
terminosCondiciones
=
generateHtmlCondiciones
(
campania
);
res
.
status
(
config
.
get
(
"
constants.HTTP_STATUS_CODE.OK
"
)).
send
(
jsonResponse
);
}
}
async
function
generateHtmlSection
(
campania
,
type
,
isMobile
)
{
async
function
generateHtmlSection
(
campania
,
type
,
isMobile
)
{
let
contenidos
=
await
getContenido
(
campania
,
type
,
isMobile
,
false
);
try
{
let
countContenido
=
await
getContenido
(
let
contenidos
=
await
getContenido
(
campania
,
type
,
isMobile
,
false
);
campania
,
let
countContenido
=
await
getContenido
(
campania
,
type
,
isMobile
,
true
);
type
,
var
posContenido
=
0
;
isMobile
,
var
fila
=
0
;
true
var
html
=
""
;
);
var
arrayJson
=
[];
var
posContenido
=
0
;
var
fila
=
0
;
contenidos
.
forEach
((
contenido
)
=>
{
var
html
=
""
;
let
json
=
{};
var
arrayJson
=
[];
var
cantidadContenido
=
countContenido
[
0
][
"
cantidad
"
];
if
(
fila
!==
contenido
.
cco_fila
)
{
contenidos
.
forEach
((
contenido
)
=>
{
if
(
fila
!=
0
)
html
=
html
+
"
</div>
"
;
let
json
=
{};
fila
=
contenido
.
cco_fila
;
var
cantidadContenido
=
countContenido
[
0
][
"
cantidad
"
];
html
=
if
(
fila
!==
contenido
.
cco_fila
){
html
+
if
(
fila
!=
0
)
html
=
html
+
"
</div>
"
;
`<div id='fila_id_
${
contenido
.
cco_fila
}
_
${
contenido
.
cco_id
}
' class='row'>`
;
fila
=
contenido
.
cco_fila
;
}
html
=
html
+
`<div id='fila_id_
${
contenido
.
cco_fila
}
_
${
contenido
.
cco_id
}
' class='row'>`
;
}
json
.
id
=
contenido
.
cco_id
;
json
.
fila
=
contenido
.
cco_fila
;
json
.
columna
=
contenido
.
cco_columna
;
json
.
tipo
=
contenido
.
cco_tipo
;
html
=
html
+
htmlAnalyzer
(
contenido
);
json
.
contenido
=
html
;
arrayJson
[
posContenido
]
=
json
;
posContenido
++
;
fila
=
contenido
.
cco_fila
;
if
(
posContenido
==
cantidadContenido
){
json
.
contenido
=
json
.
contenido
+
'
</div>
'
;
arrayJson
[
posContenido
-
1
]
=
json
;
}
html
=
""
;
});
json
.
id
=
contenido
.
cco_id
;
json
.
fila
=
contenido
.
cco_fila
;
json
.
columna
=
contenido
.
cco_columna
;
json
.
tipo
=
contenido
.
cco_tipo
;
return
arrayJson
;
html
=
html
+
htmlAnalyzer
(
contenido
);
json
.
contenido
=
html
;
arrayJson
[
posContenido
]
=
json
;
posContenido
++
;
fila
=
contenido
.
cco_fila
;
if
(
posContenido
==
cantidadContenido
)
{
json
.
contenido
=
json
.
contenido
+
"
</div>
"
;
arrayJson
[
posContenido
-
1
]
=
json
;
}
html
=
""
;
});
return
arrayJson
;
}
catch
(
err
)
{
log
.
logger
.
error
(
`Error :
${
err
.
message
}
`
);
return
[];
}
}
}
async
function
getContenido
(
campania
,
type
,
isMobile
,
isCount
)
{
async
function
getContenido
(
campania
,
type
,
isMobile
,
isCount
)
{
var
query
=
``
;
var
query
=
``
;
if
(
isCount
)
query
=
query
+
`SELECT count(*) as cantidad FROM campania_contenido `
;
if
(
isCount
)
query
=
query
+
`SELECT count(*) as cantidad FROM campania_contenido `
;
else
query
=
query
+
`SELECT * FROM campania_contenido `
;
else
query
=
query
+
`SELECT * FROM campania_contenido `
;
query
=
query
=
...
@@ -136,11 +148,15 @@ async function getContenido(campania, type, isMobile, isCount) {
...
@@ -136,11 +148,15 @@ async function getContenido(campania, type, isMobile, isCount) {
if
(
isMobile
)
if
(
isMobile
)
query
=
query
=
query
+
query
+
` and dis_id in (
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.MOBILE
"
)}
,
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.BOTH
"
)}
) `
;
` and dis_id in (
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.MOBILE
"
)}
,
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.BOTH
"
)}
) `
;
else
else
query
=
query
=
query
+
query
+
` and dis_id in (
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.DESKTOP
"
)}
,
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.BOTH
"
)}
) `
;
` and dis_id in (
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.DESKTOP
"
)}
,
${
config
.
get
(
"
constants.CONTENT_DEVICE_DISPOSITION.BOTH
"
)}
) `
;
query
=
query
+
` ORDER BY cco_fila ASC, cco_columna ASC;`
;
query
=
query
+
` ORDER BY cco_fila ASC, cco_columna ASC;`
;
//console.log(query);
//console.log(query);
...
@@ -148,86 +164,100 @@ async function getContenido(campania, type, isMobile, isCount) {
...
@@ -148,86 +164,100 @@ async function getContenido(campania, type, isMobile, isCount) {
return
doQuery
(
query
);
return
doQuery
(
query
);
}
}
function
htmlAnalyzer
(
contenido
){
function
htmlAnalyzer
(
contenido
)
{
var
html
=
""
;
var
html
=
""
;
switch
(
contenido
.
cco_tipo
)
{
case
config
.
get
(
"
constants.CONTENT_TYPE.TEXT
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<div id="texto_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
" >
${
contenido
.
cco_contenido
}
</div>`
;
html
=
html
+
'
</div>
'
;
break
;
case
config
.
get
(
"
constants.CONTENT_TYPE.IMAGE
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<img id="imagen_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
" src="
${
contenido
.
cco_contenido
}
" />`
;
html
=
html
+
'
</div>
'
;
break
;
case
config
.
get
(
"
constants.CONTENT_TYPE.VIDEO
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<div id="video_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="
${
contenido
.
cco_contenido
}
"></iframe></div>`
;
html
=
html
+
'
</div>
'
;
break
;
default
:
html
=
""
;
break
;
}
return
html
;
switch
(
contenido
.
cco_tipo
)
{
}
case
config
.
get
(
"
constants.CONTENT_TYPE.TEXT
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<div id="texto_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
" >
${
contenido
.
cco_contenido
}
</div>`
;
html
=
html
+
"
</div>
"
;
break
;
case
config
.
get
(
"
constants.CONTENT_TYPE.IMAGE
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<img id="imagen_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
" src="
${
contenido
.
cco_contenido
}
" />`
;
html
=
html
+
"
</div>
"
;
break
;
case
config
.
get
(
"
constants.CONTENT_TYPE.VIDEO
"
):
html
=
""
;
html
=
getColumnaByDisposicion
(
contenido
.
cco_disposicion_nombre
,
contenido
.
cco_columna
);
html
=
html
+
`<div id="video_fil_
${
contenido
.
cco_fila
}
_con_
${
contenido
.
cco_id
}
" class="
${
contenido
.
cco_clase_css
}
embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" src="
${
contenido
.
cco_contenido
}
"></iframe></div>`
;
html
=
html
+
"
</div>
"
;
break
;
default
:
html
=
""
;
break
;
}
function
getColumnaByDisposicion
(
nombre
,
columna
){
return
html
;
var
html
=
""
;
switch
(
nombre
){
case
"
(1)
"
:
html
=
'
<div class = "col-lg-12 col-md-12 col-sm-12 col-xs-12">
'
;
break
;
case
"
(1/2;1/2)
"
:
html
=
'
<div class = "col-lg-6 col-md-6 col-sm-12 col-xs-12">
'
;
break
;
case
"
(1/3;1/3;1/3)
"
:
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
break
;
case
"
(2/3;1/3)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-8 col-md-8 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/3;2/3)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-8 col-md-8 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/4;3/4)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-9 col-md-9 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(3/4;1/4)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-9 col-md-9 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/4;1/4;1/4;1/4)
"
:
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
break
;
}
return
html
;
}
}
function
generateHtmlCondiciones
(
campania
){
function
getColumnaByDisposicion
(
nombre
,
columna
)
{
var
html
=
""
;
switch
(
nombre
)
{
case
"
(1)
"
:
html
=
'
<div class = "col-lg-12 col-md-12 col-sm-12 col-xs-12">
'
;
break
;
case
"
(1/2;1/2)
"
:
html
=
'
<div class = "col-lg-6 col-md-6 col-sm-12 col-xs-12">
'
;
break
;
case
"
(1/3;1/3;1/3)
"
:
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
break
;
case
"
(2/3;1/3)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-8 col-md-8 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/3;2/3)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-4 col-md-4 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-8 col-md-8 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/4;3/4)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-9 col-md-9 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(3/4;1/4)
"
:
if
(
columna
===
1
)
{
html
=
'
<div class = "col-lg-9 col-md-9 col-sm-12 col-xs-12">
'
;
}
else
{
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
}
break
;
case
"
(1/4;1/4;1/4;1/4)
"
:
html
=
'
<div class = "col-lg-3 col-md-3 col-sm-12 col-xs-12">
'
;
break
;
}
return
html
;
}
function
generateHtmlCondiciones
(
campania
)
{
let
arrayJson
=
[];
let
arrayJson
=
[];
let
json
=
{};
let
json
=
{};
let
html
=
`<div id="terminos_
${
campania
[
0
].
cam_id
}
" class="gearlabs_terminos">Ver términos y condiciones <a href="
${
campania
[
0
].
cam_url_terminos_condiciones_campania
}
" target = "_blank">aquí</a></div>`
;
let
html
=
`<div id="terminos_
${
campania
[
0
].
cam_id
}
" class="gearlabs_terminos">Ver términos y condiciones <a href="
${
campania
[
0
].
cam_url_terminos_condiciones_campania
}
" target = "_blank">aquí</a></div>`
;
...
@@ -236,16 +266,14 @@ function generateHtmlCondiciones(campania){
...
@@ -236,16 +266,14 @@ function generateHtmlCondiciones(campania){
arrayJson
.
push
(
json
);
arrayJson
.
push
(
json
);
return
arrayJson
;
return
arrayJson
;
}
}
async
function
getCampanias
()
{
async
function
getCampanias
()
{
let
query
=
`SELECT * FROM campania;`
;
let
query
=
`SELECT * FROM campania;`
;
return
doQuery
(
query
);
return
doQuery
(
query
);
}
}
async
function
getCampaniaById
(
array
)
{
async
function
getCampaniaById
(
array
)
{
let
query
=
`SELECT * FROM campania WHERE cam_unique_key= ? LIMIT 1;`
;
let
query
=
`SELECT * FROM campania WHERE cam_unique_key= ? LIMIT 1;`
;
return
doQueryParams
(
query
,
array
);
return
doQueryParams
(
query
,
array
);
}
}
...
@@ -257,14 +285,14 @@ async function getTemplateById(array) {
...
@@ -257,14 +285,14 @@ async function getTemplateById(array) {
/**
/**
* Funciones core para realizar consultas sql en mysql
* Funciones core para realizar consultas sql en mysql
* @param {*} queryToDo
* @param {*} queryToDo
*/
*/
async
function
doQuery
(
queryToDo
)
{
async
function
doQuery
(
queryToDo
)
{
let
pro
=
new
Promise
((
resolve
,
reject
)
=>
{
let
pro
=
new
Promise
((
resolve
,
reject
)
=>
{
let
query
=
queryToDo
;
let
query
=
queryToDo
;
dbConn
.
query
(
query
,
function
(
err
,
result
)
{
dbConn
.
query
(
query
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
if
(
err
)
//console.log(result
);
reject
(
new
Error
(
`Ocurrio el siguiente error en la BD :
${
err
}
`
)
);
resolve
(
result
);
resolve
(
result
);
});
});
});
});
...
@@ -277,14 +305,14 @@ async function doQueryParams(queryToDo, array) {
...
@@ -277,14 +305,14 @@ async function doQueryParams(queryToDo, array) {
let
pro
=
new
Promise
((
resolve
,
reject
)
=>
{
let
pro
=
new
Promise
((
resolve
,
reject
)
=>
{
let
query
=
queryToDo
;
let
query
=
queryToDo
;
dbConn
.
query
(
query
,
array
,
function
(
err
,
result
)
{
dbConn
.
query
(
query
,
array
,
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
if
(
err
)
reject
(
new
Error
(
`Ocurrio el siguiente error en la BD :
${
err
}
`
));
resolve
(
result
);
resolve
(
result
);
});
});
});
});
return
pro
.
then
((
val
)
=>
{
return
pro
.
then
((
val
)
=>
{
return
val
;
return
val
;
});
});
}
}
module
.
exports
=
router
;
module
.
exports
=
router
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment