155 lines
4.5 KiB
JavaScript
155 lines
4.5 KiB
JavaScript
var mysql = require('mysql');
|
|
|
|
//#region ZENDION INC
|
|
var MySQLConfig = {
|
|
connectionLimit : 10,
|
|
host : 'zendioninc.com.br',
|
|
port : '3306',
|
|
user : 'zendion',
|
|
password : 'Z210203!',
|
|
database : 'zendioninc',
|
|
debug : false,
|
|
multipleStatements : true
|
|
};
|
|
|
|
global.AbreConexaoMySQL = function AbreConexaoMySQL() {
|
|
global.mysqlConnection = mysql.createPool(MySQLConfig);
|
|
console.log("MySQL Conectado! ZENDION INC");
|
|
}
|
|
AbreConexaoMySQL();
|
|
|
|
global.ExecuteQuery = function ExecuteQuery(sqlQuery, req, res, params = [], callback = null) {
|
|
mysqlConnection.query(sqlQuery, params, function (error, results, fields) {
|
|
console.log(`${new Date().toUTCString()} - ${req.originalUrl} ${(error) ? ' 500 error' : ' 200 success'}`);
|
|
res.send(JSON.stringify({ "status": ((error) ? 500 : 200), "error": error, "response": results }))
|
|
});
|
|
}
|
|
|
|
//#endregion
|
|
|
|
//#region GCA Control
|
|
var ConfigMySQLGCA = {
|
|
connectionLimit : 10,
|
|
host : 'zendioninc.com.br',
|
|
port : '3306',
|
|
user : 'zendion',
|
|
password : 'Z210203!',
|
|
database : 'GCA',
|
|
debug : false,
|
|
multipleStatements : true
|
|
};
|
|
|
|
global.AbreConexaoGCAMySQL = function AbreConexaoGCAMySQL() {
|
|
global.ConexaoMySQL_GCA = mysql.createPool(ConfigMySQLGCA);
|
|
console.log("MySQL Conectado! GCA Control");
|
|
}
|
|
AbreConexaoGCAMySQL();
|
|
|
|
global.ExecuteQueryGCA = function ExecuteQueryGCA(sqlQuery, req, res, params = [], callback = null) {
|
|
ConexaoMySQL_GCA.query(sqlQuery, params, function (error, results, fields) {
|
|
console.log(`${new Date().toUTCString()} - ${req.originalUrl} ${(error) ? ' 500 error' : ' 200 success'}`);
|
|
res.send(JSON.stringify({ "status": ((error) ? 500 : 200), "error": error, "response": results }))
|
|
});
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
//#region PRIORIE
|
|
var ConfigMySQLPriorie = {
|
|
connectionLimit : 10,
|
|
host : 'zendioninc.com.br',
|
|
port : '3306',
|
|
user : 'zendion',
|
|
password : 'Z210203!',
|
|
database : 'priorie',
|
|
debug : false,
|
|
multipleStatements : true
|
|
};
|
|
|
|
global.AbreConexaoPriorieMySQL = function AbreConexaoPriorieMySQL() {
|
|
global.ConexaoMySQL_Priorie = mysql.createPool(ConfigMySQLPriorie);
|
|
console.log("MySQL Conectado! Priorie");
|
|
}
|
|
AbreConexaoPriorieMySQL();
|
|
|
|
global.ExecuteQueryPriorie = function ExecutarQuery(sqlQuery, req, res, callback = null) {
|
|
ConexaoMySQL_Priorie.query(sqlQuery, function(error, results, fields) {
|
|
let Status = 0;
|
|
if (!error) {
|
|
Status = 200;
|
|
console.log(req.originalUrl + " success 200");
|
|
}
|
|
else {
|
|
Status = 500;
|
|
console.log(req.originalUrl + " error 500");
|
|
results = [];
|
|
}
|
|
res.send(JSON.stringify({ "status": Status, "response": results, "error": error }));
|
|
try {
|
|
callback(Status, results['insertId']);
|
|
}
|
|
catch (e) {}
|
|
});
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
//#region AGROBASE
|
|
var ConfigMySQLAgro = {
|
|
connectionLimit : 10,
|
|
host : 'zendioninc.com.br',
|
|
port : '3306',
|
|
user : 'zendion',
|
|
password : 'Z210203!',
|
|
database : 'agrobase',
|
|
debug : false,
|
|
multipleStatements : true
|
|
};
|
|
|
|
global.AbreConexaoAgroMySQL = function AbreConexaoAgroMySQL() {
|
|
global.ConexaoMySQL_Agro = mysql.createPool(ConfigMySQLAgro);
|
|
console.log("MySQL Conectado! AgroBase");
|
|
}
|
|
AbreConexaoAgroMySQL();
|
|
|
|
global.ExecuteQueryAgro = function ExecuteQueryAgro(sqlQuery, req, res, params = [], callback = null) {
|
|
ConexaoMySQL_Agro.query(sqlQuery, params, function (error, results, fields) {
|
|
console.log(`${new Date().toUTCString()} - ${req.originalUrl} ${(error) ? ' 500 error' : ' 200 success'}`);
|
|
res.send(JSON.stringify({ "status": ((error) ? 500 : 200), "error": error, "response": results }))
|
|
});
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
//#region ORIONTARD
|
|
var ConfigMySQLOriontard = {
|
|
connectionLimit : 10,
|
|
host : 'zendioninc.com.br',
|
|
port : '3306',
|
|
user : 'zendion',
|
|
password : 'Z210203!',
|
|
database : 'oriontard',
|
|
debug : false,
|
|
multipleStatements : true
|
|
};
|
|
|
|
global.AbreConexaoOriontardMySQL = function AbreConexaoOriontardMySQL() {
|
|
global.ConexaoMySQL_Oriontard = mysql.createPool(ConfigMySQLOriontard);
|
|
console.log("MySQL Conectado! Oriontard");
|
|
}
|
|
AbreConexaoOriontardMySQL();
|
|
|
|
global.ExecuteQueryOriontard = function ExecuteQueryOriontard(sqlQuery, req, res, params = [], callback = null) {
|
|
ConexaoMySQL_Oriontard.query(sqlQuery, params, function (error, results, fields) {
|
|
console.log(`${new Date().toUTCString()} - ${req.originalUrl} ${(error) ? ' 500 error' : ' 200 success'}`);
|
|
res.send(JSON.stringify({ "status": ((error) ? 500 : 200), "error": error, "response": results }))
|
|
});
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|