154 lines
3.1 KiB
JavaScript
154 lines
3.1 KiB
JavaScript
/**
|
|
* 메뉴 생성 스크립트
|
|
* 데이터베이스에 기본 메뉴 항목을 생성합니다.
|
|
*/
|
|
const { Menu } = require('../src/models');
|
|
const { sequelize } = require('../src/config/database');
|
|
require('dotenv').config();
|
|
|
|
// 관리자용 메뉴 항목
|
|
const adminMenus = [
|
|
{
|
|
title: '대시보드',
|
|
icon: 'pi pi-home',
|
|
to: '/admin',
|
|
role: 'admin',
|
|
order: 1,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '클럽 관리',
|
|
icon: 'pi pi-users',
|
|
to: '/admin/clubs',
|
|
role: 'admin',
|
|
order: 2,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '사용자 관리',
|
|
icon: 'pi pi-user',
|
|
to: '/admin/users',
|
|
role: 'admin',
|
|
order: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '구독 관리',
|
|
icon: 'pi pi-credit-card',
|
|
to: '/admin/subscriptions',
|
|
role: 'admin',
|
|
order: 4,
|
|
visible: true
|
|
}
|
|
];
|
|
|
|
// 일반 사용자용 메뉴 항목
|
|
const userMenus = [
|
|
{
|
|
title: '대시보드',
|
|
icon: 'pi pi-home',
|
|
to: '/clubs',
|
|
role: 'user',
|
|
order: 1,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '회원 관리',
|
|
icon: 'pi pi-users',
|
|
to: '/clubs/members',
|
|
role: 'user',
|
|
order: 2,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '모임 관리',
|
|
icon: 'pi pi-calendar',
|
|
to: '/clubs/meetings',
|
|
role: 'user',
|
|
order: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '점수 관리',
|
|
icon: 'pi pi-chart-bar',
|
|
to: '/clubs/meetings/scores',
|
|
role: 'user',
|
|
order: 4,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '통계',
|
|
icon: 'pi pi-chart-line',
|
|
to: '/statistics',
|
|
role: 'user',
|
|
order: 5,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '예약',
|
|
icon: 'pi pi-bookmark',
|
|
to: '/clubs/reservations',
|
|
role: 'user',
|
|
order: 6,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '이벤트 관리',
|
|
icon: 'pi pi-list',
|
|
to: '/clubs/events',
|
|
role: 'user',
|
|
order: 7,
|
|
visible: true
|
|
},
|
|
{
|
|
title: '이벤트 캘린더',
|
|
icon: 'pi pi-calendar',
|
|
to: '/clubs/events/calendar',
|
|
role: 'user',
|
|
order: 8,
|
|
visible: true
|
|
}
|
|
];
|
|
|
|
// 메뉴 생성 함수
|
|
async function createMenus() {
|
|
try {
|
|
// 데이터베이스 연결 확인
|
|
await sequelize.authenticate();
|
|
console.log('데이터베이스 연결 성공');
|
|
|
|
// 메뉴 테이블 동기화
|
|
await Menu.sync({ alter: true });
|
|
console.log('메뉴 테이블 동기화 완료');
|
|
|
|
// 기존 메뉴 항목 확인
|
|
const existingMenus = await Menu.findAll();
|
|
|
|
if (existingMenus.length > 0) {
|
|
console.log('메뉴 항목이 이미 존재합니다.');
|
|
return;
|
|
}
|
|
|
|
// 관리자용 메뉴 생성
|
|
for (const menu of adminMenus) {
|
|
await Menu.create(menu);
|
|
}
|
|
console.log('관리자용 메뉴 생성 완료');
|
|
|
|
// 일반 사용자용 메뉴 생성
|
|
for (const menu of userMenus) {
|
|
await Menu.create(menu);
|
|
}
|
|
console.log('일반 사용자용 메뉴 생성 완료');
|
|
|
|
console.log('모든 메뉴 항목이 성공적으로 생성되었습니다.');
|
|
} catch (error) {
|
|
console.error('메뉴 생성 중 오류 발생:', error);
|
|
} finally {
|
|
process.exit();
|
|
}
|
|
}
|
|
|
|
// 스크립트 실행
|
|
createMenus();
|