refactor: refs #7207 simplify code
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
23d2d2b1ea
commit
3638e9abb6
|
@ -1,36 +1,30 @@
|
|||
DELIMITER $$
|
||||
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`queueMember_updateQueue`(
|
||||
vBusinessFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Replace the queue of a worker with the queue of the new department.
|
||||
*
|
||||
* @param vBusinessFk business id
|
||||
*/
|
||||
/**
|
||||
* Elimina la entrada de la cola anterior y luego inserta la nueva para un trabajador.
|
||||
*
|
||||
* @param vBusinessFk ID del negocio
|
||||
*/
|
||||
DECLARE vNewQueue VARCHAR(10);
|
||||
DECLARE vExtension VARCHAR(10);
|
||||
DECLARE vPrevQueue VARCHAR(10);
|
||||
|
||||
SELECT d.pbxQueue, s.extension, qm.queue INTO vNewQueue, vExtension, vPrevQueue
|
||||
SELECT d.pbxQueue, s.extension, qm.queue
|
||||
INTO vNewQueue, vExtension, vPrevQueue
|
||||
FROM business b
|
||||
JOIN department d ON d.id = b.departmentFk
|
||||
JOIN pbx.sip s ON s.user_id = b.workerFk
|
||||
LEFT JOIN pbx.queueMember qm ON qm.extension = s.extension
|
||||
WHERE b.id = vBusinessFk;
|
||||
|
||||
IF vNewQueue IS NULL THEN
|
||||
DELETE FROM pbx.queueMember
|
||||
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
ELSE
|
||||
IF vPrevQueue IS NULL THEN
|
||||
INSERT INTO pbx.queueMember (queue, extension)
|
||||
|
||||
INSERT IGNORE INTO pbx.queueMember (queue, extension)
|
||||
VALUES (vNewQueue, vExtension);
|
||||
ELSE
|
||||
UPDATE pbx.queueMember
|
||||
SET queue = vNewQueue
|
||||
WHERE extension = vExtension COLLATE utf8_general_ci;
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue