Apply .gitignore cleanup

This commit is contained in:
admin
2025-10-05 09:21:04 +07:00
parent d2a7a3e478
commit 3448594bc5
3515 changed files with 20582 additions and 1501448 deletions

52
mariadb/util.sql Executable file → Normal file
View File

@@ -1,26 +1,26 @@
-- A.3 Query: “User → Effective Permissions” (global + project)
-- เปลี่ยน :userId, :projectId ตามต้องการ (projectId ใส่ NULL ได้)
SET @uid := :userId;
SET @pid := :projectId;
SELECT DISTINCT p.perm_code
FROM (
-- global roles
SELECT rp.perm_id
FROM user_roles ur
JOIN role_permissions rp ON rp.role_id = ur.role_id
WHERE ur.user_id = @uid
UNION ALL
-- project roles (ถ้ามี project)
SELECT rp.perm_id
FROM user_project_roles upr
JOIN role_permissions rp ON rp.role_id = upr.role_id
WHERE upr.user_id = @uid AND (@pid IS NOT NULL AND upr.project_id = @pid)
) x
JOIN permissions p ON p.perm_id = x.perm_id
ORDER BY p.perm_code;
-- End of A.3
-- A.3 Query: “User → Effective Permissions” (global + project)
-- เปลี่ยน :userId, :projectId ตามต้องการ (projectId ใส่ NULL ได้)
SET @uid := :userId;
SET @pid := :projectId;
SELECT DISTINCT p.perm_code
FROM (
-- global roles
SELECT rp.perm_id
FROM user_roles ur
JOIN role_permissions rp ON rp.role_id = ur.role_id
WHERE ur.user_id = @uid
UNION ALL
-- project roles (ถ้ามี project)
SELECT rp.perm_id
FROM user_project_roles upr
JOIN role_permissions rp ON rp.role_id = upr.role_id
WHERE upr.user_id = @uid AND (@pid IS NOT NULL AND upr.project_id = @pid)
) x
JOIN permissions p ON p.perm_id = x.perm_id
ORDER BY p.perm_code;
-- End of A.3