2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`workerCreateExternal`(
|
2024-01-15 11:31:03 +00:00
|
|
|
vFirstName VARCHAR(50),
|
|
|
|
vSurname1 VARCHAR(50),
|
|
|
|
vSurname2 VARCHAR(50),
|
|
|
|
vUser VARCHAR(20),
|
|
|
|
vPassword VARCHAR(50),
|
|
|
|
vWorkerCode VARCHAR(3),
|
|
|
|
vRole INT(2)
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
DECLARE vUserId INT;
|
|
|
|
DECLARE vSurnames VARCHAR(100);
|
|
|
|
|
|
|
|
INSERT INTO account.`user`(name, nickname, password, `role`, hasGrant)
|
|
|
|
SELECT vUser, vUser, MD5(vPassword), vRole, false;
|
|
|
|
|
|
|
|
SET vUserId = LAST_INSERT_ID();
|
|
|
|
|
|
|
|
IF vSurname2 IS NULL THEN
|
|
|
|
SET vSurnames = vSurname1;
|
|
|
|
ELSE
|
|
|
|
SET vSurnames = CONCAT(vSurname1, ' ', vSurname2);
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
INSERT INTO worker(id, firstName, lastName, code, isFreelance)
|
|
|
|
SELECT vUserId, vFirstName, vSurnames, vWorkerCode, true;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|