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`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
|
||||
AFTER DELETE ON `zoneIncluded`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
INSERT INTO zoneLog
|
||||
SET `action` = 'delete',
|
||||
`changedModel` = 'ZoneIncluded',
|
||||
`changedModelId` = OLD.id,
|
||||
`changedModel` = 'zoneIncluded',
|
||||
`changedModelId` = OLD.zoneFk,
|
||||
`userFk` = account.myUser_getId();
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -30,23 +30,21 @@ module.exports = Self => {
|
|||
Self.toggleIsIncluded = async(id, geoId, isIncluded, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (isIncluded === undefined)
|
||||
return models.ZoneIncluded.destroyAll({zoneFk: id, geoFk: geoId}, myOptions);
|
||||
else {
|
||||
const zoneIncluded = await models.ZoneIncluded.findOne({where: {zoneFk: id, geoFk: geoId}}, myOptions);
|
||||
if (zoneIncluded)
|
||||
return zoneIncluded.updateAttribute('isIncluded', isIncluded, myOptions);
|
||||
else {
|
||||
return models.ZoneIncluded.create({
|
||||
zoneFk: id,
|
||||
geoFk: geoId,
|
||||
isIncluded: isIncluded
|
||||
}, myOptions);
|
||||
}
|
||||
}
|
||||
|
||||
const zoneIncluded = await models.ZoneIncluded.findOne({where: {zoneFk: id, geoFk: geoId}}, myOptions);
|
||||
|
||||
if (zoneIncluded)
|
||||
return zoneIncluded.updateAttribute('isIncluded', isIncluded, myOptions);
|
||||
|
||||
return models.ZoneIncluded.create({
|
||||
zoneFk: id,
|
||||
geoFk: geoId,
|
||||
isIncluded: isIncluded
|
||||
}, myOptions);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue