-- V12: 공통코드 / 역할 / 메뉴 / 시스템설정 초기 데이터

-- 1. 공통코드 그룹 18개
INSERT INTO common_code_group (group_code, group_name, description, is_system, sort_order) VALUES
 ('AGENT_STATUS',    '설계사상태',     'ACTIVE/LEAVE/SUSPEND',    'Y', 10),
 ('CONTRACT_STATUS', '계약상태',       'ACTIVE/LAPSE/...',         'Y', 20),
 ('SETTLE_STATUS',   '정산상태',       'CALCULATED/CONFIRMED/..',  'Y', 30),
 ('PAYMENT_STATUS',  '지급상태',       'PENDING/SENT/DONE/FAIL',  'Y', 40),
 ('LEDGER_STATUS',   '원장상태',       'CALCULATED/...',           'Y', 50),
 ('PAY_CYCLE',       '납입주기',       'MONTHLY/QUARTERLY/...',    'Y', 60),
 ('PAY_METHOD',      '납입방법',       'CARD/AUTO/CASH',           'Y', 70),
 ('INSURANCE_TYPE',  '보험종류',       'WHOLE_LIFE/...',           'Y', 80),
 ('ORG_TYPE',        '조직유형',       'HQ/BR/TM',                 'Y', 90),
 ('GRADE_GROUP',     '직급그룹',       'NORMAL/MANAGER/EXEC',      'Y',100),
 ('BANK_CODE',       '은행코드',       '주요 은행',                'N',110),
 ('YN',              'Y/N',           '예/아니오',                'Y',120),
 ('APPROVE_STATUS',  '승인상태',       'PENDING/APPROVED/...',     'Y',130),
 ('RECON_STATUS',    '대사상태',       'PENDING/MATCHED/DIFF',     'Y',140),
 ('EXCEPTION_DIRECTION','예외방향',    'PLUS/MINUS',               'Y',150),
 ('CHANGE_TYPE',     '인사변동유형',   'JOIN/LEAVE/TRANSFER...',   'Y',160),
 ('NOTI_TYPE',       '알림유형',       'INFO/WARN/ERROR',          'Y',170),
 ('MENU_TYPE',       '메뉴유형',       'DIRECTORY/PAGE/LINK',      'Y',180);

-- 2. 공통코드 상세 (대표 40건)
INSERT INTO common_code (group_code, code, code_name, sort_order) VALUES
 ('AGENT_STATUS','ACTIVE','정상',10),
 ('AGENT_STATUS','LEAVE','퇴사',20),
 ('AGENT_STATUS','SUSPEND','정지',30),
 ('CONTRACT_STATUS','ACTIVE','유효',10),
 ('CONTRACT_STATUS','LAPSE','실효',20),
 ('CONTRACT_STATUS','REVIVE','부활',30),
 ('CONTRACT_STATUS','TERMINATE','해지',40),
 ('SETTLE_STATUS','CALCULATED','계산완료',10),
 ('SETTLE_STATUS','CONFIRMED','확정',20),
 ('SETTLE_STATUS','HOLD','보류',30),
 ('SETTLE_STATUS','PAID','지급완료',40),
 ('PAYMENT_STATUS','PENDING','대기',10),
 ('PAYMENT_STATUS','SENT','이체요청',20),
 ('PAYMENT_STATUS','DONE','완료',30),
 ('PAYMENT_STATUS','FAIL','실패',40),
 ('PAY_CYCLE','MONTHLY','월납',10),
 ('PAY_CYCLE','QUARTERLY','분기납',20),
 ('PAY_CYCLE','ANNUAL','연납',30),
 ('PAY_CYCLE','LUMP','일시납',40),
 ('PAY_METHOD','CARD','카드',10),
 ('PAY_METHOD','AUTO','자동이체',20),
 ('PAY_METHOD','CASH','현금',30),
 ('INSURANCE_TYPE','WHOLE_LIFE','종신',10),
 ('INSURANCE_TYPE','TERM','정기',20),
 ('INSURANCE_TYPE','SAVINGS','저축',30),
 ('INSURANCE_TYPE','HEALTH','건강',40),
 ('ORG_TYPE','HQ','본부',10),
 ('ORG_TYPE','BR','지점',20),
 ('ORG_TYPE','TM','팀',30),
 ('YN','Y','예',10),
 ('YN','N','아니오',20),
 ('APPROVE_STATUS','PENDING','대기',10),
 ('APPROVE_STATUS','APPROVED','승인',20),
 ('APPROVE_STATUS','REJECTED','반려',30),
 ('RECON_STATUS','PENDING','대기',10),
 ('RECON_STATUS','MATCHED','일치',20),
 ('RECON_STATUS','DIFF','차이',30),
 ('EXCEPTION_DIRECTION','PLUS','지급',10),
 ('EXCEPTION_DIRECTION','MINUS','공제',20),
 ('NOTI_TYPE','INFO','정보',10),
 ('NOTI_TYPE','WARN','경고',20),
 ('NOTI_TYPE','ERROR','오류',30);

-- 3. 역할 4건
INSERT INTO role (role_code, role_name, role_desc, role_level, is_system) VALUES
 ('SUPER_ADMIN','슈퍼관리자','전체 권한',          100,'Y'),
 ('ADMIN',      '관리자',    '시스템 운영',         80, 'Y'),
 ('MANAGER',    '매니저',    '업무 담당',           50, 'Y'),
 ('AGENT',      '설계사',    '본인 정보 조회',      10, 'Y');

-- 4. 메뉴 (대분류 10건 + 세부 일부)
INSERT INTO menu (menu_code, menu_name, menu_type, menu_path, menu_icon, menu_level, sort_order) VALUES
 ('DASHBOARD','대시보드','PAGE','/','DashboardOutlined',1,10),
 ('ORG','조직관리','DIRECTORY',NULL,'TeamOutlined',1,20),
 ('CONTRACT','계약관리','DIRECTORY',NULL,'FileTextOutlined',1,30),
 ('RULE','수수료규정','DIRECTORY',NULL,'SettingOutlined',1,40),
 ('RECEIVE','데이터수신','DIRECTORY',NULL,'CloudUploadOutlined',1,50),
 ('LEDGER','원장관리','DIRECTORY',NULL,'BookOutlined',1,60),
 ('SETTLE','정산관리','DIRECTORY',NULL,'CalculatorOutlined',1,70),
 ('PAYMENT','지급관리','DIRECTORY',NULL,'BankOutlined',1,80),
 ('REPORT','리포트','DIRECTORY',NULL,'BarChartOutlined',1,90),
 ('SYSTEM','시스템관리','DIRECTORY',NULL,'ToolOutlined',1,100);

-- 5. 시스템 설정 13건
INSERT INTO system_config (config_key, config_value, config_group, value_type, description) VALUES
 ('TAX_RATE',          '3.3',  'TAX',     'NUMBER',  '원천세율(%)'),
 ('SETTLE_DAY',        '5',    'SETTLE',  'NUMBER',  '정산 기준일'),
 ('PAY_DAY',           '10',   'SETTLE',  'NUMBER',  '지급일'),
 ('PASSWORD_MIN_LEN',  '8',    'SECURITY','NUMBER',  '비밀번호 최소 길이'),
 ('PASSWORD_EXPIRE',   '90',   'SECURITY','NUMBER',  '비밀번호 만료일(일)'),
 ('LOGIN_FAIL_LIMIT',  '5',    'SECURITY','NUMBER',  '로그인 실패 잠금 횟수'),
 ('TOKEN_EXPIRE',      '7200', 'SECURITY','NUMBER',  '토큰 만료(초)'),
 ('UPLOAD_MAX_MB',     '100',  'COMMON',  'NUMBER',  '업로드 최대 용량(MB)'),
 ('ALLOW_EXTENSIONS',  'xlsx,xls,csv,pdf,jpg,png','COMMON','STRING','허용 확장자'),
 ('SMTP_HOST',         '',     'MAIL',    'STRING',  'SMTP 서버'),
 ('SMTP_PORT',         '587',  'MAIL',    'NUMBER',  'SMTP 포트'),
 ('BATCH_RETRY',       '3',    'BATCH',   'NUMBER',  '배치 재시도 횟수'),
 ('BATCH_TIMEOUT',     '7200', 'BATCH',   'NUMBER',  '배치 타임아웃(초)');
