declaring models deliveryMan
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
8a3231b615
commit
530c300ea5
|
@ -9,10 +9,12 @@ CREATE TABLE `vn`.`routeDeliveryMan` (
|
|||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `vn`.`routeDeliveryManAgency` (
|
||||
`deliveryManFk` INT UNSIGNED NOT NULL,
|
||||
`agencyModeFk` INT NOT NULL,
|
||||
CONSTRAINT `routeDeliveryManAgency_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `vn`.`agencyMode`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT `routeDeliveryManAgency_FK_1` FOREIGN KEY (`deliveryManFk`) REFERENCES `vn`.`routeDeliveryMan`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
`deliveryManFk` int(10) unsigned NOT NULL,
|
||||
`agencyModeFk` int(11) NOT NULL,
|
||||
PRIMARY KEY (`deliveryManFk`),
|
||||
KEY `routeDeliveryManAgency_FK` (`agencyModeFk`),
|
||||
CONSTRAINT `routeDeliveryManAgency_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE,
|
||||
CONSTRAINT `routeDeliveryManAgency_FK_1` FOREIGN KEY (`deliveryManFk`) REFERENCES `routeDeliveryMan` (`id`) ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
ALTER TABLE `vn`.`route` ADD `invoiceOutFk` varchar(10) NULL;
|
||||
|
@ -20,4 +22,5 @@ ALTER TABLE `vn`.`route` ADD CONSTRAINT `route_FK` FOREIGN KEY (`invoiceOutFk`)
|
|||
|
||||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('DeliveryMan', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
('DeliveryMan', '*', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||
('DeliveryManAgency', '*', '*', 'ALLOW', 'ROLE', 'employee');
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('getDeliveryMan', {
|
||||
description: 'Returns the list of delivery men',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: false,
|
||||
description: 'The delivery man id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
accessType: 'READ',
|
||||
returns: {
|
||||
type: 'Object',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/getDeliveryMan`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.getDeliveryMan = async(id, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const deliveryMan = await models.DeliveryMan.find({
|
||||
where: {
|
||||
id
|
||||
},
|
||||
include: [{
|
||||
relation: 'deliveryManAgency',
|
||||
scope:
|
||||
{
|
||||
include: {
|
||||
relation: 'agencyMode'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'supplier'
|
||||
}]
|
||||
});
|
||||
|
||||
return deliveryMan;
|
||||
};
|
||||
};
|
|
@ -29,7 +29,7 @@
|
|||
"foreignKey": "supplierFk"
|
||||
},
|
||||
"deliveryManAgency": {
|
||||
"type": "hasMany",
|
||||
"type": "hasOne",
|
||||
"model": "DeliveryManAgency",
|
||||
"foreignKey": "deliveryManFk"
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ module.exports = Self => {
|
|||
require('../methods/route/driverRoutePdf')(Self);
|
||||
require('../methods/route/driverRouteEmail')(Self);
|
||||
require('../methods/route/sendSms')(Self);
|
||||
require('../methods/route/getDeliveryMan')(Self);
|
||||
require('../methods/route/updateDeliveryMan')(Self);
|
||||
|
||||
Self.validate('kmStart', validateDistance, {
|
||||
|
|
Loading…
Reference in New Issue