-- =====================================================
-- 新安江模块 单位信息表 ST_XAJ_UNIT 建表语句 (达梦数据库)
-- Schema: TBA_GX
-- =====================================================
CREATE TABLE TBA_GX.ST_XAJ_UNIT (
    UNIT_CODE   VARCHAR2(64)  NOT NULL,
    UNIT_NAME   VARCHAR2(200) NOT NULL,
    TYPE        VARCHAR2(50),
    ADDR        VARCHAR2(500),
    LINKMAN     VARCHAR2(50),
    TELE        VARCHAR2(50),
    MAIL        VARCHAR2(100),
    FAX         VARCHAR2(50),
    URL         VARCHAR2(200),
    NOTE        VARCHAR2(500),
    ORDER_NUM   INT           DEFAULT 0,
    CREATE_BY   VARCHAR2(64),
    CREATE_TIME DATETIME,
    UPDATE_BY   VARCHAR2(64),
    UPDATE_TIME DATETIME,
    REMARK      VARCHAR2(500),
    DEL_FLAG    CHAR(1)       DEFAULT '0',
    PRIMARY KEY (UNIT_CODE)
);
COMMENT ON TABLE  TBA_GX.ST_XAJ_UNIT IS '新安江共享单位信息表';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.UNIT_CODE   IS '单位编码(主键)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.UNIT_NAME   IS '单位名称';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.TYPE        IS '单位类型';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.ADDR        IS '地址';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.LINKMAN     IS '联系人';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.TELE        IS '电话';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.MAIL        IS '邮箱';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.FAX         IS '传真';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.URL         IS '网址';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.NOTE        IS '备注说明';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.ORDER_NUM   IS '显示排序';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.CREATE_BY   IS '创建者';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.UPDATE_BY   IS '更新者';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.REMARK      IS '备注';
COMMENT ON COLUMN TBA_GX.ST_XAJ_UNIT.DEL_FLAG    IS '删除标志(0正常 1删除)';

-- =====================================================
-- 新安江模块 业务域信息表 ST_XAJ_BIZ 建表语句 (达梦数据库)
-- =====================================================
CREATE TABLE TBA_GX.ST_XAJ_BIZ (
    BIZ_CODE     VARCHAR2(64)  NOT NULL,
    BIZ_NAME     VARCHAR2(200) NOT NULL,
    BIZ_TYPE     VARCHAR2(50),
    BIZ_UNIT     VARCHAR2(64),
    BIZ_IMPL_TYPE VARCHAR2(20),
    BIZ_IMPL_URL  VARCHAR2(500),
    BIZ_STATE    CHAR(1)       DEFAULT '0',
    DATA_FREQ    VARCHAR2(20),
    BIZ_NOTE     VARCHAR2(1000),
    ORDER_NUM    INT           DEFAULT 0,
    CREATE_BY    VARCHAR2(64),
    CREATE_TIME  DATETIME,
    UPDATE_BY    VARCHAR2(64),
    UPDATE_TIME  DATETIME,
    REMARK       VARCHAR2(500),
    DEL_FLAG     CHAR(1)       DEFAULT '0',
    PRIMARY KEY (BIZ_CODE)
);
COMMENT ON TABLE  TBA_GX.ST_XAJ_BIZ IS '新安江业务域信息表';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_CODE      IS '业务编码(主键)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_NAME      IS '业务名称';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_TYPE      IS '业务类型';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_UNIT      IS '提供单位编码(关联ST_XAJ_UNIT.UNIT_CODE)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_IMPL_TYPE IS '实现方式(API/FILE/DB)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_IMPL_URL  IS '接口地址/实现路径';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_STATE     IS '状态(0正常 1停用)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.DATA_FREQ     IS '数据频率(实时/小时/日/月)';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.BIZ_NOTE      IS '数据说明';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.ORDER_NUM     IS '显示排序';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.CREATE_BY     IS '创建者';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.CREATE_TIME   IS '创建时间';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.UPDATE_BY     IS '更新者';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.UPDATE_TIME   IS '更新时间';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.REMARK        IS '备注';
COMMENT ON COLUMN TBA_GX.ST_XAJ_BIZ.DEL_FLAG      IS '删除标志(0正常 1删除)';

-- =====================================================
-- 菜单插入SQL (新安江模块下增加单位管理/业务域管理)
-- 先查询 SYS_MENU 最大 menu_id，当前已记录为 1118，下面从 1119 开始
-- =====================================================
-- 假设新安江模块父菜单ID，先定位：若未知，请自行查找 xajgl 模块父 menu_id
-- 这里提供模板，parent_id 需改为实际的新安江模块父菜单ID，菜单路径按实际调整

-- 子菜单1：单位信息管理 (1119)
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK)
VALUES (1119, '单位信息管理', 0 /* TODO: 改为实际新安江父菜单ID */, 4, 'unit', 'xajgl/unit/index', NULL, NULL, 1, 0, 'C', '0', '0', 'xajgl:unit:list', 'peoples', 'admin', SYSDATE, '', NULL, '新安江单位信息管理菜单');

-- 子菜单2：业务域管理 (1120)
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK)
VALUES (1120, '业务域管理',   0 /* TODO: 改为实际新安江父菜单ID */, 5, 'biz',  'xajgl/biz/index',  NULL, NULL, 1, 0, 'C', '0', '0', 'xajgl:biz:list',  'list',    'admin', SYSDATE, '', NULL, '新安江业务域管理菜单');

-- 单位管理按钮级权限 (1121~1125)
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1121, '单位查询', 1119, 1, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:unit:query',  '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1122, '单位新增', 1119, 2, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:unit:add',    '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1123, '单位修改', 1119, 3, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:unit:edit',   '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1124, '单位删除', 1119, 4, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:unit:remove', '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1125, '单位导出', 1119, 5, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:unit:export', '#', 'admin', SYSDATE, '', NULL, '');

-- 业务域管理按钮级权限 (1126~1130)
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1126, '业务域查询', 1120, 1, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:biz:query',  '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1127, '业务域新增', 1120, 2, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:biz:add',    '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1128, '业务域修改', 1120, 3, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:biz:edit',   '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1129, '业务域删除', 1120, 4, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:biz:remove', '#', 'admin', SYSDATE, '', NULL, '');
INSERT INTO SYS_MENU (MENU_ID, MENU_NAME, PARENT_ID, ORDER_NUM, PATH, COMPONENT, QUERY, ROUTE_NAME, IS_FRAME, IS_CACHE, MENU_TYPE, VISIBLE, STATUS, PERMS, ICON, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, REMARK) VALUES (1130, '业务域导出', 1120, 5, '', NULL, NULL, NULL, 1, 0, 'F', '0', '0', 'xajgl:biz:export', '#', 'admin', SYSDATE, '', NULL, '');
