2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost`
|
2024-01-15 11:31:03 +00:00
|
|
|
SQL SECURITY DEFINER
|
|
|
|
VIEW `vn`.`departmentTree`
|
|
|
|
AS SELECT `node`.`id` AS `id`,
|
|
|
|
concat(
|
|
|
|
CONVERT(
|
|
|
|
repeat(repeat(' ', 5), COUNT(`parent`.`id`) - 1) USING utf8mb3
|
|
|
|
),
|
|
|
|
`node`.`name`
|
|
|
|
) AS `dep`
|
|
|
|
FROM (
|
|
|
|
`vn`.`department` `node`
|
|
|
|
JOIN `vn`.`department` `parent`
|
|
|
|
)
|
|
|
|
WHERE `node`.`lft` BETWEEN `parent`.`lft` AND `parent`.`rgt`
|
|
|
|
GROUP BY `node`.`id`
|
|
|
|
ORDER BY `node`.`lft`
|