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`.`logShow`(vOriginFk INT, vEntity VARCHAR(45))
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Muestra las acciones realizadas por el usuario
|
|
|
|
*
|
|
|
|
* @param vOriginFk Id del registro de origen
|
|
|
|
* @param vEntity Nombre que hace referencia a la tabla.
|
|
|
|
*/
|
|
|
|
DECLARE vTableName VARCHAR(45);
|
|
|
|
|
|
|
|
SET vTableName = CONCAT(vEntity, 'Log');
|
|
|
|
|
|
|
|
SET @qryLog := CONCAT(
|
|
|
|
'SELECT ot.id, ot.originFk, ot.userFk, u.name, ot.action, ot.creationDate, ot.description FROM ', vTableName, ' AS ot',
|
|
|
|
' INNER JOIN account.user u ON u.id = ot.userFk',
|
|
|
|
' WHERE ot.originFk = ', vOriginFk, ' ORDER BY ot.creationDate DESC'
|
|
|
|
);
|
|
|
|
|
|
|
|
PREPARE stmt FROM @qryLog;
|
|
|
|
EXECUTE stmt;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|