feat: position field + menu role permissions management

This commit is contained in:
pray4skylark
2026-06-08 10:43:18 +09:00
parent 15b73e7bc0
commit fe90547457
12 changed files with 513 additions and 5 deletions
@@ -0,0 +1,69 @@
ALTER TABLE tb_employee ADD COLUMN IF NOT EXISTS position VARCHAR(50);
CREATE SEQUENCE IF NOT EXISTS sq_menu_permissions INCREMENT BY 50;
CREATE TABLE tb_menu_permission (
id BIGSERIAL PRIMARY KEY,
menu_key VARCHAR(100) NOT NULL UNIQUE,
menu_name VARCHAR(200) NOT NULL,
parent_key VARCHAR(100),
allowed_roles TEXT NOT NULL DEFAULT '["ADMIN","MANAGER","EMPLOYEE"]',
sort_order INTEGER DEFAULT 0,
created_at TIMESTAMP,
updated_at TIMESTAMP,
is_deleted CHAR(1) DEFAULT 'N'
);
INSERT INTO tb_menu_permission (menu_key, menu_name, parent_key, allowed_roles, sort_order) VALUES
('dashboard', 'Dashboard', null, '["ADMIN","MANAGER","EMPLOYEE"]', 1),
('issues', 'SR Issues', null, '["ADMIN","MANAGER","EMPLOYEE"]', 2),
('dispatch', 'Dispatch', null, '["ADMIN","MANAGER","EMPLOYEE"]', 3),
('itam', 'ITAM (Assets)', null, '["ADMIN","MANAGER"]', 4),
('itam-hub', 'Asset Hub', 'itam', '["ADMIN","MANAGER"]', 5),
('itam-register', 'Register', 'itam', '["ADMIN","MANAGER"]', 6),
('itam-checkout', 'Check-out', 'itam', '["ADMIN","MANAGER"]', 7),
('itam-checkin', 'Check-in', 'itam', '["ADMIN","MANAGER"]', 8),
('employees', 'Employees', null, '["ADMIN","MANAGER"]', 5),
('projects', 'Projects', null, '["ADMIN","MANAGER"]', 6),
('reports', 'Work Reports', null, '["ADMIN","MANAGER","EMPLOYEE"]', 7),
('reports-review', 'Report Review', null, '["ADMIN","MANAGER"]', 8),
('training', 'Training', null, '["ADMIN","MANAGER","EMPLOYEE"]', 9),
('calendar', 'Calendar', null, '["ADMIN","MANAGER","EMPLOYEE"]', 10),
('profile', 'Profile', null, '["ADMIN","MANAGER","EMPLOYEE"]', 11),
('profile-portfolio', 'Portfolio', 'profile', '["ADMIN","MANAGER","EMPLOYEE"]', 12),
('settings', 'Admin', null, '["ADMIN"]', 99),
('settings-codes', 'Codes', 'settings', '["ADMIN"]', 100),
('settings-accounts', 'Accounts', 'settings', '["ADMIN"]', 101),
('settings-batch-employees', 'Batch Employees', 'settings', '["ADMIN"]', 102),
('settings-system', 'System', 'settings', '["ADMIN"]', 103),
('settings-notification', 'Notification', 'settings', '["ADMIN"]', 104),
('settings-audit', 'Audit Log', 'settings', '["ADMIN"]', 105),
('settings-menus', 'Menu Permissions', 'settings', '["ADMIN"]', 106);
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'STAFF', '사원', 1, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'STAFF');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'SENIOR', '주임', 2, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'SENIOR');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'ASSISTANT_MANAGER', '대리', 3, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'ASSISTANT_MANAGER');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'MANAGER', '과장', 4, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'MANAGER');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'DEPUTY_GENERAL_MANAGER', '차장', 5, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'DEPUTY_GENERAL_MANAGER');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'GENERAL_MANAGER', '부장', 6, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'GENERAL_MANAGER');
INSERT INTO tb_common_code (id, group_code, code_value, code_name, sort_order, is_active, created_at, updated_at)
SELECT nextval('sq_common_codes'), 'POSITION', 'DIRECTOR', '이사', 7, 'Y', NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM tb_common_code WHERE group_code = 'POSITION' AND code_value = 'DIRECTOR');