feat: refs #7187 check if is freelancer on insert & update
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
22006ea3fb
commit
976b18203e
|
@ -3,6 +3,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_
|
|||
BEFORE INSERT ON `deviceProductionUser`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
DECLARE vHasPda BOOLEAN;
|
||||
DECLARE visFreelancer BOOLEAN;
|
||||
DECLARE vUserName VARCHAR(50);
|
||||
|
||||
SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk;
|
||||
|
||||
SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk;
|
||||
|
||||
SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer;
|
||||
|
||||
IF NOT vIsFreelancer AND vHasPda THEN
|
||||
CALL util.throw('You can only have one PDA');
|
||||
ELSE
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -3,6 +3,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionUser_
|
|||
BEFORE UPDATE ON `deviceProductionUser`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
DECLARE vHasPda BOOLEAN;
|
||||
DECLARE visFreelancer BOOLEAN;
|
||||
DECLARE vUserName VARCHAR(50);
|
||||
|
||||
SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = NEW.userFk;
|
||||
|
||||
SELECT name INTO vUserName FROM account.user WHERE id = NEW.userFk;
|
||||
|
||||
SELECT account.user_hasRoleId(vUserName, (SELECT id FROM role WHERE name = 'freelancer')) INTO vIsFreelancer;
|
||||
|
||||
IF NOT vIsFreelancer AND vHasPda THEN
|
||||
CALL util.throw('You can only have one PDA');
|
||||
ELSE
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE vn.deviceProductionUser DROP INDEX IF EXISTS deviceProductionUser_UN;
|
||||
|
Loading…
Reference in New Issue