delore-crm-core 1.0.6 → 1.0.8
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/db/models.js +8 -4
- package/package.json +1 -1
package/db/models.js
CHANGED
|
@@ -5,8 +5,12 @@ const listModels = [];
|
|
|
5
5
|
const listModelsIn = [];
|
|
6
6
|
const logger = require('../utils/logger.js');
|
|
7
7
|
const listTablesValidDel = [];
|
|
8
|
+
let pathViews = '';
|
|
8
9
|
|
|
9
10
|
const models = {
|
|
11
|
+
setPathViews: function (path) {
|
|
12
|
+
pathViews = path;
|
|
13
|
+
},
|
|
10
14
|
Migration: function () {
|
|
11
15
|
return migration();
|
|
12
16
|
},
|
|
@@ -380,8 +384,7 @@ async function createViews() {
|
|
|
380
384
|
//
|
|
381
385
|
// Lista diretório com as views
|
|
382
386
|
//
|
|
383
|
-
|
|
384
|
-
var files = fs.readdirSync(directoryPath);
|
|
387
|
+
var files = fs.readdirSync(pathViews);
|
|
385
388
|
if (files) {
|
|
386
389
|
for (var i = 0; i < files.length; i++) {
|
|
387
390
|
var file = files[i];
|
|
@@ -394,7 +397,7 @@ async function createViews() {
|
|
|
394
397
|
|
|
395
398
|
if (listViewExist.length == 0) {
|
|
396
399
|
console.log('* * * criando a view ' + viewName);
|
|
397
|
-
var sql = fs.readFileSync(
|
|
400
|
+
var sql = fs.readFileSync(pathViews + '/' + file, 'utf8');
|
|
398
401
|
console.log(sql);
|
|
399
402
|
await sequelize.query(sql);
|
|
400
403
|
}
|
|
@@ -892,6 +895,7 @@ function getContentNumber(field) {
|
|
|
892
895
|
}
|
|
893
896
|
|
|
894
897
|
async function canDelete(tableName, id, companyId) {
|
|
898
|
+
const sequelize = require('delore-crm-core').sequelizeDB.getSequelize()
|
|
895
899
|
var sql = 'Select sum(sub) total from (';
|
|
896
900
|
|
|
897
901
|
var subSQL = '';
|
|
@@ -931,8 +935,8 @@ async function makeSQLTransf(tableName, idOri, idDes, companyId) {
|
|
|
931
935
|
}
|
|
932
936
|
|
|
933
937
|
async function canDelete2(tableName, id) {
|
|
938
|
+
const sequelize = require('delore-crm-core').sequelizeDB.getSequelize()
|
|
934
939
|
var sql = 'Select sum(sub) total from (';
|
|
935
|
-
|
|
936
940
|
var subSQL = '';
|
|
937
941
|
listTablesValidDel.forEach((table) => {
|
|
938
942
|
if (table.tableDelete === tableName) {
|