From 0b21cc231cc17d47e41c9b59695a335d21d72eb2 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Date: Thu, 15 Mar 2018 13:47:47 +0100 Subject: [PATCH] new model expedition, add fixtures for the model and update ACL --- services/db/04-fixtures.sql | 6 +++ services/db/changes/1.0.2/01-ACLinserts.sql | 3 +- ...4.ticketVolume.sql => 04-ticketVolume.sql} | 0 services/db/changes/1.0.2/05-expedition.sql | 19 +++++++ .../loopback/common/models/agency-mode.json | 10 +++- services/ticket/common/models/expedition.json | 51 +++++++++++++++++++ services/ticket/server/model-config.json | 3 ++ 7 files changed, 90 insertions(+), 2 deletions(-) rename services/db/changes/1.0.2/{04.ticketVolume.sql => 04-ticketVolume.sql} (100%) create mode 100644 services/db/changes/1.0.2/05-expedition.sql create mode 100644 services/ticket/common/models/expedition.json diff --git a/services/db/04-fixtures.sql b/services/db/04-fixtures.sql index 047720eeb..6ce558cc5 100644 --- a/services/db/04-fixtures.sql +++ b/services/db/04-fixtures.sql @@ -397,6 +397,12 @@ INSERT INTO `vn`.`item`(`id`, `name`,`typeFk`,`size`,`inkFk`,`category`,`stems`, (4, 'Mark I', 1, 60, 'AMR', 'EXT', 1, 1, 'Iron Mans first armor', 1, 05080000, 1, 2, 0, NULL, 0, 66090, 2), (5, 'Mjolnir', 3, 30, 'AZR', 'EXT', 1, 2, 'Thors hammer!', 2, 06021010, 1, 2, 0, NULL, 0, 67350, 2); +INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `checked`, `workerFk`) + VALUES + ( 1, 1, 1, 0, CURDATE(), 1, 0, 2, 1), + ( 2, 1, 1, 1, CURDATE(), 2, 1, 0, 2), + ( 3, 2, 2, 2, CURDATE(), 3, 2, 0, NULL); + INSERT INTO `vn`.`packaging`(`id`, `volume`, `width`, `height`, `depth`, `isPackageReturnable`, `created`, `itemFk`, `price`) VALUES (1, 0.00, 10, 10, 0, 0, CURDATE(), 1, 1.50), diff --git a/services/db/changes/1.0.2/01-ACLinserts.sql b/services/db/changes/1.0.2/01-ACLinserts.sql index 635e6145d..be55aeb0f 100644 --- a/services/db/changes/1.0.2/01-ACLinserts.sql +++ b/services/db/changes/1.0.2/01-ACLinserts.sql @@ -8,4 +8,5 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `pri INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Packaging', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Packaging', '*', 'WRITE', 'ALLOW', 'ROLE', 'logistic'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SaleChecked', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SaleComponent', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('SaleComponent', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Expedition', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); diff --git a/services/db/changes/1.0.2/04.ticketVolume.sql b/services/db/changes/1.0.2/04-ticketVolume.sql similarity index 100% rename from services/db/changes/1.0.2/04.ticketVolume.sql rename to services/db/changes/1.0.2/04-ticketVolume.sql diff --git a/services/db/changes/1.0.2/05-expedition.sql b/services/db/changes/1.0.2/05-expedition.sql new file mode 100644 index 000000000..1baeeb480 --- /dev/null +++ b/services/db/changes/1.0.2/05-expedition.sql @@ -0,0 +1,19 @@ +USE `vn`; +CREATE + OR REPLACE ALGORITHM = UNDEFINED + DEFINER = `root`@`%` + SQL SECURITY DEFINER +VIEW `vn`.`expedition` AS + SELECT + `e`.`expeditions_id` AS `id`, + `e`.`agency_id` AS `agencyModeFk`, + `e`.`ticket_id` AS `ticketFk`, + `e`.`EsBulto` AS `isBox`, + `e`.`odbc_date` AS `created`, + `e`.`Id_Article` AS `itemFk`, + `e`.`counter` AS `counter`, + `e`.`checked` AS `checked`, + `e`.`workerFk` AS `workerFk` + FROM + `vn2008`.`expeditions` `e` + diff --git a/services/loopback/common/models/agency-mode.json b/services/loopback/common/models/agency-mode.json index ebac22a77..d29695ae3 100644 --- a/services/loopback/common/models/agency-mode.json +++ b/services/loopback/common/models/agency-mode.json @@ -41,5 +41,13 @@ "model": "AgencyType", "foreignKey": "agencyTypeFk" } - } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] } diff --git a/services/ticket/common/models/expedition.json b/services/ticket/common/models/expedition.json new file mode 100644 index 000000000..da070e04b --- /dev/null +++ b/services/ticket/common/models/expedition.json @@ -0,0 +1,51 @@ +{ + "name": "Expedition", + "base": "VnModel", + "options": { + "mysql": { + "table": "expedition" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "isBox": { + "type": "Number" + }, + "created": { + "type": "Date" + }, + "counter": { + "type": "Number" + }, + "checked": { + "type": "Number" + } + }, + "relations": { + "ticket": { + "type": "belongsTo", + "model": "Ticket", + "foreignKey": "ticketFk" + }, + "agencyMode": { + "type": "belongsTo", + "model": "agency-mode", + "foreignKey": "agencyModeFk" + }, + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } + } + \ No newline at end of file diff --git a/services/ticket/server/model-config.json b/services/ticket/server/model-config.json index 8a2b05c49..2bcc701ef 100644 --- a/services/ticket/server/model-config.json +++ b/services/ticket/server/model-config.json @@ -25,6 +25,9 @@ }, "SaleComponent": { "dataSource": "vn" + }, + "Expedition": { + "dataSource": "vn" } }