From 50bebbba36aea8dba67f483642e7f82d57e8d65d Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 17 Dec 2018 11:28:39 +0100 Subject: [PATCH] Unified datasources --- .eslintrc.yml | 2 +- docker-compose.tpl.yml | 1 - gulpfile.js | 20 +---- .../common/models/claim-development.json | 3 +- services/claim/common/models/claim-end.json | 3 +- .../claim/common/models/claim-reason.json | 3 +- .../claim/common/models/claim-redelivery.json | 3 +- .../common/models/claim-responsible.json | 3 +- .../claim/common/models/claim-result.json | 3 +- services/claim/common/models/claim-state.json | 3 +- .../common/models/address-observation.json | 3 +- .../client/common/models/bank-entity.json | 3 +- .../client/common/models/client-contact.json | 3 +- .../client/common/models/client-credit.json | 3 +- .../client/common/models/client-risk.json | 3 +- services/client/common/models/defaulter.json | 3 +- .../common/models/observation-type.json | 3 +- services/client/common/models/tpv-error.json | 3 +- .../client/common/models/tpv-merchant.json | 3 +- .../client/common/models/tpv-response.json | 3 +- services/client/server/model-config.json | 6 +- services/item/common/models/genus.json | 2 +- services/item/common/models/item-barcode.json | 3 +- services/item/common/models/item-log.json | 3 +- services/item/common/models/item-niche.json | 3 +- services/item/common/models/itemTypeTag.json | 5 +- services/item/common/models/specie.json | 2 +- services/item/server/model-config.json | 4 +- services/loopback/common/models/account.json | 2 +- .../common/models/claim-beginning.json | 3 +- .../common/models/claim-destination.json | 3 +- .../loopback/common/models/claim-ratio.json | 3 +- services/loopback/common/models/claim.json | 3 +- services/loopback/common/models/fieldAcl.json | 2 +- services/loopback/common/models/item-tag.json | 3 +- services/loopback/common/models/order.json | 2 +- services/loopback/common/models/tag.json | 3 +- .../common/models/ticket-observation.json | 3 +- .../common/models/ticket-tracking.json | 3 +- .../loopback/common/models/user-config.json | 3 +- services/loopback/common/models/user.json | 5 ++ .../loopback/common/models/worker-mana.json | 2 +- services/loopback/server/datasources.json | 77 ++----------------- services/loopback/server/model-config.json | 38 ++++++--- services/loopback/server/server.js | 12 ++- services/order/common/models/order-row.json | 2 +- services/order/server/model-config.json | 2 +- .../ticket/common/models/sale-tracking.json | 3 +- 48 files changed, 97 insertions(+), 179 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 233dd57c7..315c9418a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -26,7 +26,7 @@ rules: bracketSpacing: 0 space-infix-ops: 1 prefer-const: 0 - curly: [error, multi-or-nest] + curly: [error, multi, consitent] indent: [error, 4] arrow-parens: [error, as-needed] jasmine/no-focused-tests: 0 \ No newline at end of file diff --git a/docker-compose.tpl.yml b/docker-compose.tpl.yml index efbb564e9..c64e6b98b 100644 --- a/docker-compose.tpl.yml +++ b/docker-compose.tpl.yml @@ -6,5 +6,4 @@ services: context: ./services/nginx ports: - 80:80 - - 443:443 links: [] diff --git a/gulpfile.js b/gulpfile.js index aeaab9bc0..b72abdeac 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,6 @@ const exec = require('child_process').exec; const PluginError = require('plugin-error'); const argv = require('minimist')(process.argv.slice(2)); const log = require('fancy-log'); -const environment = require('gulp-env'); // Configuration @@ -41,12 +40,6 @@ gulp.task('default', () => { return gulp.start('services', 'client'); }); -gulp.task('environment', async () => { - await environment({ - file: '.env.json' - }); -}); - gulp.task('client', ['build-clean'], async () => { await runSequenceP(['routes', 'locales'], 'watch', 'webpack-dev-server'); }); @@ -61,7 +54,7 @@ gulp.task('services', async () => { /** * Starts backend services. */ -gulp.task('services-only', ['environment'], async () => { +gulp.task('services-only', async () => { const services = await getServices(); for (let service of services) require(service.index).start(service.port); @@ -147,7 +140,7 @@ gulp.task('install', () => { // Deployment gulp.task('build', ['clean'], async () => { - await runSequenceP(['environment', 'routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']); + await runSequenceP(['routes', 'locales', 'webpack', 'docker-compose', 'nginx-conf']); }); gulp.task('docker-compose', async () => { @@ -179,11 +172,7 @@ gulp.task('docker-compose', async () => { }, ports: [`${service.port}:${defaultPort}`], environment: { - NODE_ENV: '${NODE_ENV}', - salixHost: '${salixHost}', - salixPort: '${salixPort}', - salixUser: '${salixUser}', - salixPassword: '${salixPassword}' + NODE_ENV: '${NODE_ENV}' } }; @@ -200,9 +189,6 @@ gulp.task('docker-compose', async () => { restart: 'unless-stopped', volumes: ['/config:/config'] }); - service.build.labels = { - 'salix.tag': imageTag - }; } let ymlString = yaml.safeDump(composeYml); diff --git a/services/claim/common/models/claim-development.json b/services/claim/common/models/claim-development.json index f82d1009b..7452f7ded 100644 --- a/services/claim/common/models/claim-development.json +++ b/services/claim/common/models/claim-development.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimDevelopment", - "database": "vn" + "table": "claimDevelopment" } }, "properties": { diff --git a/services/claim/common/models/claim-end.json b/services/claim/common/models/claim-end.json index 01c6c494a..8f835ee84 100644 --- a/services/claim/common/models/claim-end.json +++ b/services/claim/common/models/claim-end.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimEnd", - "database": "vn" + "table": "claimEnd" } }, "properties": { diff --git a/services/claim/common/models/claim-reason.json b/services/claim/common/models/claim-reason.json index 3ecb9c1db..562acc14e 100644 --- a/services/claim/common/models/claim-reason.json +++ b/services/claim/common/models/claim-reason.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimReason", - "database": "vn" + "table": "claimReason" } }, "properties": { diff --git a/services/claim/common/models/claim-redelivery.json b/services/claim/common/models/claim-redelivery.json index 8cb2e77c6..8611a3a44 100644 --- a/services/claim/common/models/claim-redelivery.json +++ b/services/claim/common/models/claim-redelivery.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimRedelivery", - "database": "vn" + "table": "claimRedelivery" } }, "properties": { diff --git a/services/claim/common/models/claim-responsible.json b/services/claim/common/models/claim-responsible.json index a14800984..6bd06605b 100644 --- a/services/claim/common/models/claim-responsible.json +++ b/services/claim/common/models/claim-responsible.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimResponsible", - "database": "vn" + "table": "claimResponsible" } }, "properties": { diff --git a/services/claim/common/models/claim-result.json b/services/claim/common/models/claim-result.json index d260603e7..468f271de 100644 --- a/services/claim/common/models/claim-result.json +++ b/services/claim/common/models/claim-result.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimResult", - "database": "vn" + "table": "claimResult" } }, "properties": { diff --git a/services/claim/common/models/claim-state.json b/services/claim/common/models/claim-state.json index 5d29d4ea2..2f76a9f77 100644 --- a/services/claim/common/models/claim-state.json +++ b/services/claim/common/models/claim-state.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimState", - "database": "vn" + "table": "claimState" } }, "properties": { diff --git a/services/client/common/models/address-observation.json b/services/client/common/models/address-observation.json index 147e19f07..c338d972b 100644 --- a/services/client/common/models/address-observation.json +++ b/services/client/common/models/address-observation.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "addressObservation", - "database": "vn" + "table": "addressObservation" } }, "properties": { diff --git a/services/client/common/models/bank-entity.json b/services/client/common/models/bank-entity.json index c8f94e33c..8835c492d 100644 --- a/services/client/common/models/bank-entity.json +++ b/services/client/common/models/bank-entity.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "bankEntity", - "database": "vn" + "table": "bankEntity" } }, "properties": { diff --git a/services/client/common/models/client-contact.json b/services/client/common/models/client-contact.json index 0c06af814..467dce757 100644 --- a/services/client/common/models/client-contact.json +++ b/services/client/common/models/client-contact.json @@ -9,8 +9,7 @@ }, "options": { "mysql": { - "table": "clientContact", - "database": "vn" + "table": "clientContact" } }, "validateUpsert": true, diff --git a/services/client/common/models/client-credit.json b/services/client/common/models/client-credit.json index 96ea26829..2b71fbe2d 100644 --- a/services/client/common/models/client-credit.json +++ b/services/client/common/models/client-credit.json @@ -4,8 +4,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "clientCredit", - "database": "vn" + "table": "clientCredit" } }, "validateUpsert": true, diff --git a/services/client/common/models/client-risk.json b/services/client/common/models/client-risk.json index 11380fd6f..f76483fca 100644 --- a/services/client/common/models/client-risk.json +++ b/services/client/common/models/client-risk.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "clientRisk", - "database": "vn" + "table": "clientRisk" } }, "properties": { diff --git a/services/client/common/models/defaulter.json b/services/client/common/models/defaulter.json index d6d510df7..8d50356f1 100644 --- a/services/client/common/models/defaulter.json +++ b/services/client/common/models/defaulter.json @@ -4,8 +4,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "defaulter", - "database": "vn" + "table": "defaulter" } }, "properties": { diff --git a/services/client/common/models/observation-type.json b/services/client/common/models/observation-type.json index ac3b84092..e4a9ceba5 100644 --- a/services/client/common/models/observation-type.json +++ b/services/client/common/models/observation-type.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "observationType", - "database": "vn" + "table": "observationType" } }, "properties": { diff --git a/services/client/common/models/tpv-error.json b/services/client/common/models/tpv-error.json index af9084160..61e2a7156 100644 --- a/services/client/common/models/tpv-error.json +++ b/services/client/common/models/tpv-error.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "tpvError", - "database": "hedera" + "table": "hedera.tpvError" } }, "properties": { diff --git a/services/client/common/models/tpv-merchant.json b/services/client/common/models/tpv-merchant.json index e9be094c2..db5c937d8 100644 --- a/services/client/common/models/tpv-merchant.json +++ b/services/client/common/models/tpv-merchant.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "tpvMerchant", - "database": "hedera" + "table": "hedera.tpvMerchant" } }, "properties": { diff --git a/services/client/common/models/tpv-response.json b/services/client/common/models/tpv-response.json index d658813fc..d3a382b5f 100644 --- a/services/client/common/models/tpv-response.json +++ b/services/client/common/models/tpv-response.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "tpvResponse", - "database": "hedera" + "table": "hedera.tpvResponse" } }, "properties": { diff --git a/services/client/server/model-config.json b/services/client/server/model-config.json index ba216c886..b9542955d 100644 --- a/services/client/server/model-config.json +++ b/services/client/server/model-config.json @@ -48,13 +48,13 @@ "dataSource": "vn" }, "TpvError": { - "dataSource": "hedera" + "dataSource": "vn" }, "TpvMerchant": { - "dataSource": "hedera" + "dataSource": "vn" }, "TpvResponse": { - "dataSource": "hedera" + "dataSource": "vn" }, "Defaulter": { "dataSource": "vn" diff --git a/services/item/common/models/genus.json b/services/item/common/models/genus.json index 1026e6f05..48eab3169 100644 --- a/services/item/common/models/genus.json +++ b/services/item/common/models/genus.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "genus" + "table": "edi.genus" } }, "properties": { diff --git a/services/item/common/models/item-barcode.json b/services/item/common/models/item-barcode.json index 8c089609f..324f23a6c 100644 --- a/services/item/common/models/item-barcode.json +++ b/services/item/common/models/item-barcode.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "itemBarcode", - "database": "vn" + "table": "itemBarcode" } }, "properties": { diff --git a/services/item/common/models/item-log.json b/services/item/common/models/item-log.json index 4f784b74f..76fcc4104 100644 --- a/services/item/common/models/item-log.json +++ b/services/item/common/models/item-log.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "itemLog", - "database": "vn" + "table": "itemLog" } }, "properties": { diff --git a/services/item/common/models/item-niche.json b/services/item/common/models/item-niche.json index 61ae42ec2..74fae2faa 100644 --- a/services/item/common/models/item-niche.json +++ b/services/item/common/models/item-niche.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "itemPlacement", - "database": "vn" + "table": "itemPlacement" } }, "properties": { diff --git a/services/item/common/models/itemTypeTag.json b/services/item/common/models/itemTypeTag.json index 581c58079..ca374e00e 100644 --- a/services/item/common/models/itemTypeTag.json +++ b/services/item/common/models/itemTypeTag.json @@ -3,9 +3,8 @@ "base": "VnModel", "options": { "mysql": { - "table": "itemTypeTag", - "database": "vn" - } + "table": "itemTypeTag" + } }, "properties": { "id": { diff --git a/services/item/common/models/specie.json b/services/item/common/models/specie.json index afa669af3..1388be53b 100644 --- a/services/item/common/models/specie.json +++ b/services/item/common/models/specie.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "specie" + "table": "edi.specie" } }, "properties": { diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json index 410ee3dd2..ea4b70b58 100644 --- a/services/item/server/model-config.json +++ b/services/item/server/model-config.json @@ -18,10 +18,10 @@ "dataSource": "vn" }, "Specie": { - "dataSource": "edi" + "dataSource": "vn" }, "Genus": { - "dataSource": "edi" + "dataSource": "vn" }, "ItemTypeTag": { "dataSource": "vn" diff --git a/services/loopback/common/models/account.json b/services/loopback/common/models/account.json index feb90fa7f..e087208d6 100644 --- a/services/loopback/common/models/account.json +++ b/services/loopback/common/models/account.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "user" + "table": "account.user" } }, "properties": { diff --git a/services/loopback/common/models/claim-beginning.json b/services/loopback/common/models/claim-beginning.json index d74fe0dbe..50506122a 100644 --- a/services/loopback/common/models/claim-beginning.json +++ b/services/loopback/common/models/claim-beginning.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimBeginning", - "database": "vn" + "table": "claimBeginning" } }, "properties": { diff --git a/services/loopback/common/models/claim-destination.json b/services/loopback/common/models/claim-destination.json index 6a0774449..8782fb815 100644 --- a/services/loopback/common/models/claim-destination.json +++ b/services/loopback/common/models/claim-destination.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimDestination", - "database": "vn" + "table": "claimDestination" } }, "properties": { diff --git a/services/loopback/common/models/claim-ratio.json b/services/loopback/common/models/claim-ratio.json index b856514f2..196db72f6 100644 --- a/services/loopback/common/models/claim-ratio.json +++ b/services/loopback/common/models/claim-ratio.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claimRatio", - "database": "vn" + "table": "claimRatio" } }, "validateUpsert": true, diff --git a/services/loopback/common/models/claim.json b/services/loopback/common/models/claim.json index 049dbe3ca..38d508725 100644 --- a/services/loopback/common/models/claim.json +++ b/services/loopback/common/models/claim.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "claim", - "database": "vn" + "table": "claim" } }, "properties": { diff --git a/services/loopback/common/models/fieldAcl.json b/services/loopback/common/models/fieldAcl.json index 977139048..25ed949b9 100644 --- a/services/loopback/common/models/fieldAcl.json +++ b/services/loopback/common/models/fieldAcl.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "fieldAcl" + "table": "salix.fieldAcl" } }, "properties": { diff --git a/services/loopback/common/models/item-tag.json b/services/loopback/common/models/item-tag.json index 2eca420e3..7d3860dda 100644 --- a/services/loopback/common/models/item-tag.json +++ b/services/loopback/common/models/item-tag.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "itemTag", - "database": "vn" + "table": "itemTag" } }, "properties": { diff --git a/services/loopback/common/models/order.json b/services/loopback/common/models/order.json index 0c58396d9..e50e404cf 100644 --- a/services/loopback/common/models/order.json +++ b/services/loopback/common/models/order.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "order" + "table": "hedera.order" } }, "properties": { diff --git a/services/loopback/common/models/tag.json b/services/loopback/common/models/tag.json index 22af888da..4cd1ad74e 100644 --- a/services/loopback/common/models/tag.json +++ b/services/loopback/common/models/tag.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "tag", - "database": "vn" + "table": "tag" } }, "properties": { diff --git a/services/loopback/common/models/ticket-observation.json b/services/loopback/common/models/ticket-observation.json index 73fb71139..e5b0169c1 100644 --- a/services/loopback/common/models/ticket-observation.json +++ b/services/loopback/common/models/ticket-observation.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "ticketObservation", - "database": "vn" + "table": "ticketObservation" } }, "properties": { diff --git a/services/loopback/common/models/ticket-tracking.json b/services/loopback/common/models/ticket-tracking.json index 176f84b27..b1f2769d4 100644 --- a/services/loopback/common/models/ticket-tracking.json +++ b/services/loopback/common/models/ticket-tracking.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "ticketTracking", - "database": "vn" + "table": "ticketTracking" } }, "properties": { diff --git a/services/loopback/common/models/user-config.json b/services/loopback/common/models/user-config.json index 4e4974bfb..336f26f63 100644 --- a/services/loopback/common/models/user-config.json +++ b/services/loopback/common/models/user-config.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "userConfig", - "database": "vn" + "table": "userConfig" } }, "properties": { diff --git a/services/loopback/common/models/user.json b/services/loopback/common/models/user.json index 2f79cebdb..0756d2093 100644 --- a/services/loopback/common/models/user.json +++ b/services/loopback/common/models/user.json @@ -1,6 +1,11 @@ { "name": "user", "base": "User", + "options": { + "mysql": { + "table": "salix.user" + } + }, "properties": { "id": { "id": true, diff --git a/services/loopback/common/models/worker-mana.json b/services/loopback/common/models/worker-mana.json index 33b8b6ff9..509067e35 100644 --- a/services/loopback/common/models/worker-mana.json +++ b/services/loopback/common/models/worker-mana.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "workerMana" + "table": "bs.workerMana" } }, "properties": { diff --git a/services/loopback/server/datasources.json b/services/loopback/server/datasources.json index f54fdd189..cfc7bd67e 100644 --- a/services/loopback/server/datasources.json +++ b/services/loopback/server/datasources.json @@ -1,4 +1,4 @@ - { +{ "db": { "connector": "memory" }, @@ -7,77 +7,12 @@ "timezone": "CET", "database": "vn", "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", - "multipleStatements": true, - "connectTimeout": 20000, - "acquireTimeout": 20000 - }, - "salix": { - "connector": "vn-mysql", - "timezone": "CET", - "database": "salix", - "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", - "multipleStatements": true, - "connectTimeout": 20000, - "acquireTimeout": 20000 - }, - "account": { - "connector": "vn-mysql", - "timezone": "CET", - "database": "account", - "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", - "multipleStatements": true, - "connectTimeout": 20000, - "acquireTimeout": 20000 - }, - "edi": { - "connector": "vn-mysql", - "timezone": "CET", - "database": "edi", - "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", - "multipleStatements": true, - "connectTimeout": 20000, - "acquireTimeout": 20000 - }, - "bs": { - "connector": "vn-mysql", - "timezone": "CET", - "database": "bs", - "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", - "multipleStatements": true, - "connectTimeout": 20000, - "acquireTimeout": 20000 - }, - "hedera": { - "connector": "vn-mysql", - "timezone": "CET", - "database": "hedera", - "debug": false, - "host": "${salixHost}", - "port": "${salixPort}", - "username": "${salixUser}", - "password": "${salixPassword}", + "host": "localhost", + "port": "3306", + "username": "root", + "password": "root", "multipleStatements": true, "connectTimeout": 20000, "acquireTimeout": 20000 } - } +} diff --git a/services/loopback/server/model-config.json b/services/loopback/server/model-config.json index b41bad50b..6535f86bd 100644 --- a/services/loopback/server/model-config.json +++ b/services/loopback/server/model-config.json @@ -1,9 +1,14 @@ { "user": { - "dataSource": "salix" + "dataSource": "vn" }, "AccessToken": { - "dataSource": "salix", + "dataSource": "vn", + "options": { + "mysql": { + "table": "salix.AccessToken" + } + }, "relations": { "user": { "type": "belongsTo", @@ -13,7 +18,12 @@ } }, "ACL": { - "dataSource": "salix" + "dataSource": "vn", + "options": { + "mysql": { + "table": "salix.ACL" + } + } }, "Claim": { "dataSource": "vn" @@ -22,7 +32,7 @@ "dataSource": "vn" }, "FieldAcl": { - "dataSource": "salix" + "dataSource": "vn" }, "ObservationType": { "dataSource": "vn" @@ -34,13 +44,23 @@ "dataSource": "vn" }, "RoleMapping": { - "dataSource": "salix" + "dataSource": "vn", + "options": { + "mysql": { + "table": "salix.RoleMapping" + } + } }, "Role": { - "dataSource": "salix" + "dataSource": "vn", + "options": { + "mysql": { + "table": "salix.Role" + } + } }, "Account": { - "dataSource": "account" + "dataSource": "vn" }, "Address": { "dataSource": "vn" @@ -151,7 +171,7 @@ "dataSource": "vn" }, "WorkerMana": { - "dataSource": "bs" + "dataSource": "vn" }, "DeliveryMethod": { "dataSource": "vn" @@ -178,6 +198,6 @@ "dataSource": "vn" }, "Order": { - "dataSource": "hedera" + "dataSource": "vn" } } \ No newline at end of file diff --git a/services/loopback/server/server.js b/services/loopback/server/server.js index 0fcdfae79..b82231cf6 100644 --- a/services/loopback/server/server.js +++ b/services/loopback/server/server.js @@ -11,11 +11,12 @@ let _resolveConnector = DataSource._resolveConnector; DataSource._resolveConnector = function(name) { let testPath = `${__dirname}/connectors/${name}.js`; - if (fs.existsSync(testPath)) + if (fs.existsSync(testPath)) { return { connector: require(testPath), error: null }; + } return _resolveConnector.apply(this, arguments); }; @@ -104,9 +105,8 @@ function vnBoot(app, rootDir, rootModule) { let config = require('./config.json'); - for (let key in config) { + for (let key in config) app.set(key, config[key]); - } let modelConfigFiles = [ `${__dirname}/model-config.json`, @@ -115,9 +115,10 @@ function vnBoot(app, rootDir, rootModule) { let modelConfig = {}; - for (file of modelConfigFiles) + for (file of modelConfigFiles) { if (fs.existsSync(file)) Object.assign(modelConfig, require(file)); + } let bootOptions = { appRootDir: __dirname, @@ -142,6 +143,9 @@ function vnBoot(app, rootDir, rootModule) { ] }; + if (fs.existsSync(`/config`)) + bootOptions.dsRootDir = `/config`; + boot(app, bootOptions, function(err) { if (err) throw err; if (require.main === rootModule) diff --git a/services/order/common/models/order-row.json b/services/order/common/models/order-row.json index 77c1d654d..44d5a103a 100644 --- a/services/order/common/models/order-row.json +++ b/services/order/common/models/order-row.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "orderRow" + "table": "hedera.orderRow" } }, "properties": { diff --git a/services/order/server/model-config.json b/services/order/server/model-config.json index 98711c87b..9dae9f5d9 100644 --- a/services/order/server/model-config.json +++ b/services/order/server/model-config.json @@ -1,5 +1,5 @@ { "OrderRow": { - "dataSource": "hedera" + "dataSource": "vn" } } diff --git a/services/ticket/common/models/sale-tracking.json b/services/ticket/common/models/sale-tracking.json index aba08be29..7936f827f 100644 --- a/services/ticket/common/models/sale-tracking.json +++ b/services/ticket/common/models/sale-tracking.json @@ -3,8 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "saleTracking", - "database": "vn" + "table": "saleTracking" } }, "properties": {