feat: refs #8381 add agencyModeFk to travel thermograph and create AgencyModeIncoming model #3369

Open
jgallego wants to merge 4 commits from 8381-thermographTravel into dev
7 changed files with 64 additions and 1 deletions
Showing only changes of commit 4f68a7d262 - Show all commits

View File

@ -0,0 +1,9 @@
CREATE OR REPLACE DEFINER=`vn`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`agencyModeIncoming` AS
SELECT
am.id,
am.name
FROM `vn`.`agencyMode` AS am
JOIN `vn`.`agencyIncoming` AS ai
ON am.id = ai.agencyModeFk;

View File

@ -0,0 +1,6 @@
ALTER TABLE `vn`.`agencyIncoming`
ADD CONSTRAINT `fk_agencyIncoming_agencyMode`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyMode`(`id`)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@ -0,0 +1,7 @@
ALTER TABLE `vn`.`travelThermograph`
ADD COLUMN `agencyModeFk` INT(11) NULL AFTER `editorFk`,
ADD CONSTRAINT `travelThermograph_agencyIncoming_fk`
FOREIGN KEY (`agencyModeFk`)
REFERENCES `agencyIncoming`(`agencyModeFk`)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -57,6 +57,10 @@ module.exports = Self => {
arg: 'hasFileAttached',
type: 'Boolean',
description: 'True if has an attached file'
}, {
arg: 'agencyModeFk',
type: 'Number',
description: 'Carrier'
}],
returns: {type: 'object', root: true},
http: {path: `/:id/saveThermograph`, verb: 'POST'}
@ -76,6 +80,7 @@ module.exports = Self => {
reference,
description,
hasFileAttached,
agencyModeFk,
options
) => {
const models = Self.app.models;
@ -119,6 +124,7 @@ module.exports = Self => {
minTemperature,
temperatureFk,
warehouseFk: warehouseId,
agencyModeFk,
}, myOptions);
if (tx) await tx.commit();

View File

@ -22,5 +22,8 @@
},
"Temperature": {
"dataSource": "vn"
},
"AgencyModeIncoming": {
"dataSource": "vn"
}
}
}

View File

@ -0,0 +1,27 @@
{
"name": "AgencyModeIncoming",
"base": "VnModel",
"options": {
"mysql": {
"table": "agencyModeIncoming"
}
},
"properties": {
"id": {
"type": "number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -58,6 +58,11 @@
"type": "belongsTo",
"model": "Thermograph",
"foreignKey": "thermographFk"
},
"agencyMode": {
"type": "belongsTo",
"model": "AgencyMode",
"foreignKey": "agencyModeFk"
}
}
}