refactor(toggleIsIcluded): actualizo la versión y modifico el proc refs #5749
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
541926d3f7
commit
8d44bb8867
|
@ -13,15 +13,14 @@ DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`;
|
||||||
USE `vn`;
|
USE `vn`;
|
||||||
|
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
$$
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
|
||||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
|
|
||||||
AFTER DELETE ON `zoneIncluded`
|
AFTER DELETE ON `zoneIncluded`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO zoneLog
|
INSERT INTO zoneLog
|
||||||
SET `action` = 'delete',
|
SET `action` = 'delete',
|
||||||
`changedModel` = 'ZoneIncluded',
|
`changedModel` = 'zoneIncluded',
|
||||||
`changedModelId` = OLD.id,
|
`changedModelId` = OLD.zoneFk,
|
||||||
`userFk` = account.myUser_getId();
|
`userFk` = account.myUser_getId();
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -30,23 +30,21 @@ module.exports = Self => {
|
||||||
Self.toggleIsIncluded = async(id, geoId, isIncluded, options) => {
|
Self.toggleIsIncluded = async(id, geoId, isIncluded, options) => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
if (isIncluded === undefined)
|
if (isIncluded === undefined)
|
||||||
return models.ZoneIncluded.destroyAll({zoneFk: id, geoFk: geoId}, myOptions);
|
return models.ZoneIncluded.destroyAll({zoneFk: id, geoFk: geoId}, myOptions);
|
||||||
else {
|
|
||||||
const zoneIncluded = await models.ZoneIncluded.findOne({where: {zoneFk: id, geoFk: geoId}}, myOptions);
|
const zoneIncluded = await models.ZoneIncluded.findOne({where: {zoneFk: id, geoFk: geoId}}, myOptions);
|
||||||
if (zoneIncluded)
|
|
||||||
return zoneIncluded.updateAttribute('isIncluded', isIncluded, myOptions);
|
if (zoneIncluded)
|
||||||
else {
|
return zoneIncluded.updateAttribute('isIncluded', isIncluded, myOptions);
|
||||||
return models.ZoneIncluded.create({
|
|
||||||
zoneFk: id,
|
return models.ZoneIncluded.create({
|
||||||
geoFk: geoId,
|
zoneFk: id,
|
||||||
isIncluded: isIncluded
|
geoFk: geoId,
|
||||||
}, myOptions);
|
isIncluded: isIncluded
|
||||||
}
|
}, myOptions);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue