/*
 Navicat Premium Dump SQL

 Source Server         : 开发环境-本地
 Source Server Type    : MySQL
 Source Server Version : 80407 (8.4.7)
 Source Host           : localhost:3306
 Source Schema         : cc_admin

 Target Server Type    : MySQL
 Target Server Version : 80407 (8.4.7)
 File Encoding         : 65001

 Date: 23/01/2026 17:08:01
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for nl_admin
-- ----------------------------
DROP TABLE IF EXISTS `nl_admin`;
CREATE TABLE `nl_admin`  (
                             `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户ID',
                             `open_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'OpenID，后期整合萧康服务中心会用到',
                             `avatar` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '头像',
                             `nick_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '昵称',
                             `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码',
                             `phone` char(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户手机',
                             `email` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户邮箱',
                             `code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '业务员推广码',
                             `role_id` int NOT NULL DEFAULT 0 COMMENT '角色',
                             `province_id` int NOT NULL DEFAULT 0 COMMENT '省',
                             `city_id` int NOT NULL DEFAULT 0 COMMENT '市',
                             `reg_ip` bigint NOT NULL DEFAULT 0 COMMENT '注册IP',
                             `last_login_time` int NOT NULL DEFAULT 0 COMMENT '最后登录时间',
                             `ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '0' COMMENT '最后登录IP',
                             `ip_table` json NOT NULL COMMENT '常用登录IP地址列表',
                             `operation_password` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '操作密码',
                             `desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '备注',
                             `status` tinyint NOT NULL DEFAULT 1 COMMENT '用户状态 0正常 1禁用',
                             `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                             `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                             `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                             PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '管理员表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_admin
-- ----------------------------
INSERT INTO `nl_admin` VALUES (1, 'nl_28686ad68682180e26836c721a52', '', '超管', '$2y$12$FXKlnItms3NoCLsJKQyVa.03kuRq8ltzdmc.ksf7rLKKPfGznpjnu', '15100000000', 'workerqi@163.com', '517117', 1, 0, 0, 0, 0, '127.0.0.1', '[\"127.0.0.1\"]', '0', '', 1, 0, 1747026536, 0);

-- ----------------------------
-- Table structure for nl_admin_notice
-- ----------------------------
DROP TABLE IF EXISTS `nl_admin_notice`;
CREATE TABLE `nl_admin_notice`  (
                                    `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                                    `title` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '消息标题',
                                    `detail` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '简介',
                                    `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '消息内容',
                                    `type` int NOT NULL DEFAULT 0 COMMENT '消息类型',
                                    `user_id` int NOT NULL DEFAULT 0 COMMENT '关联用户ID',
                                    `status` int NOT NULL DEFAULT 0 COMMENT '状态 0：未读 1：已读',
                                    `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                    `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                    `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                                    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 84 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '管理员消息列表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_admin_notice
-- ----------------------------

-- ----------------------------
-- Table structure for nl_api_op_log
-- ----------------------------
DROP TABLE IF EXISTS `nl_api_op_log`;
CREATE TABLE `nl_api_op_log`  (
                                  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                                  `user_id` int NOT NULL COMMENT '操作用户ID',
                                  `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作路由',
                                  `method` tinyint(1) NOT NULL DEFAULT 0 COMMENT '请求方式 0：未知 1：GET 2：POST',
                                  `controller` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作的控制器',
                                  `ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作者IP地址',
                                  `param` json NOT NULL COMMENT '请求携带参数',
                                  `result` json NOT NULL COMMENT '返回json',
                                  `type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '操作状态 0：成功 1：失败',
                                  `result_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '返回状态码',
                                  `platform_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '平台类型 0：总后台 1：门店后台 2：小程序',
                                  `belong_id` int NOT NULL DEFAULT 0 COMMENT '所属平台ID',
                                  `user_type` int NOT NULL DEFAULT 0 COMMENT '用户类型',
                                  `equipment` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作系统',
                                  `browser` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '浏览器',
                                  `created_at` int NOT NULL DEFAULT 0 COMMENT '操作时间',
                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 16860 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '新的后台API访问日志记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_api_op_log
-- ----------------------------

-- ----------------------------
-- Table structure for nl_code_generation
-- ----------------------------
DROP TABLE IF EXISTS `nl_code_generation`;
CREATE TABLE `nl_code_generation`  (
                                       `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '用户ID',
                                       `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '菜单标题',
                                       `file_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '文件名称',
                                       `path` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '下载链接',
                                       `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '生成参数',
                                       `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                       `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                       `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                                       PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '代码生成记录' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_code_generation
-- ----------------------------

-- ----------------------------
-- Table structure for nl_database_change_log
-- ----------------------------
DROP TABLE IF EXISTS `nl_database_change_log`;
CREATE TABLE `nl_database_change_log`  (
                                           `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                                           `user_id` int NOT NULL DEFAULT 0 COMMENT '操作用户ID',
                                           `table_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '表名',
                                           `operation_type` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '操作类型：structure_change, data_change, sql_query',
                                           `operation_detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '操作详情（JSON格式）',
                                           `sql_statement` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '执行的SQL语句',
                                           `before_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '变更前数据（JSON，可选）',
                                           `after_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '变更后数据（JSON，可选）',
                                           `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                           PRIMARY KEY (`id`) USING BTREE,
                                           INDEX `idx_table_name`(`table_name` ASC) USING BTREE,
                                           INDEX `idx_operation_type`(`operation_type` ASC) USING BTREE,
                                           INDEX `idx_created_at`(`created_at` ASC) USING BTREE,
                                           INDEX `idx_table_created`(`table_name` ASC, `created_at` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '数据库变更记录表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of nl_database_change_log
-- ----------------------------

-- ----------------------------
-- Table structure for nl_file
-- ----------------------------
DROP TABLE IF EXISTS `nl_file`;
CREATE TABLE `nl_file`  (
                            `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                            `user_id` int NOT NULL DEFAULT 0 COMMENT '用户ID',
                            `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '文件地址',
                            `type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '文件类型 0：图片 1：视频 2：音频 3：excel 4：压缩包 ',
                            `source` tinyint(1) NOT NULL DEFAULT 0 COMMENT '来源 0：后台 1：用户端',
                            `created_at` int NOT NULL COMMENT '上传时间',
                            `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                            `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                            PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 84 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '文件表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_file
-- ----------------------------

-- ----------------------------
-- Table structure for nl_menu
-- ----------------------------
DROP TABLE IF EXISTS `nl_menu`;
CREATE TABLE `nl_menu`  (
                            `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                            `title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '菜单标题',
                            `icon` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '菜单图标',
                            `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '页面Name，全局唯一',
                            `path` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '访问路由',
                            `component` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '组件路径需要去掉 views/ 和 .vue',
                            `redirect` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '父级菜单重定向的子集菜单',
                            `keep_alive` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否开启页面缓存 0：开启 1：关闭',
                            `hide_in_menu` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否将页面展示在菜单栏 0：展示 1：隐藏',
                            `affix_tab` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否为置顶页 0：是 1：否',
                            `badge` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '菜单的徽标',
                            `badge_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '用于配置页面的徽标类型，0：dot 小红点 1：normal 文本',
                            `badge_variants` tinyint(1) NOT NULL DEFAULT 0 COMMENT '用于配置页面的徽标颜色 \r\n0：default 1：destructive 2：primary 3：success 4： warning',
                            `iframe_src` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '内嵌的页面路径',
                            `pid` int NOT NULL DEFAULT 0 COMMENT '父级菜单id',
                            `sort` int NOT NULL DEFAULT 0 COMMENT '排序',
                            `query` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '默认查询参数',
                            `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                            `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                            `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                            PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '菜单表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_menu
-- ----------------------------
INSERT INTO `nl_menu` VALUES (1, '概览', 'twemoji:house-with-garden', 'Dashboard', '/dashobard', 'BasicLayout', '', 0, 0, 1, '', 0, 0, '', 0, -1, '', 1734485082, 1734486088, 0);
INSERT INTO `nl_menu` VALUES (2, '分析页', 'lucide:area-chart', 'Analytics', '/analytics', '/dashboard/analytics/index', '', 1, 0, 0, '', 0, 0, '', 1, 0, '', 1734485206, 1734485814, 0);
INSERT INTO `nl_menu` VALUES (3, '工作台', 'carbon:workspace', 'Workspace', '/workspace', '/dashboard/workspace/index', '', 1, 0, 1, '', 0, 0, '', 1, 0, '', 1734486030, 0, 0);
INSERT INTO `nl_menu` VALUES (4, '关于', 'lucide:copyright', 'About', '/about', '/_core/about/index.vue', '', 1, 0, 1, '', 0, 0, '', 0, 999999999, '', 0, 0, 0);
INSERT INTO `nl_menu` VALUES (5, '基础管理', 'logos:openjs-foundation-icon', 'System', '/system', 'BasicLayout', '', 0, 0, 1, '', 0, 0, '', 0, 1000, '', 1734486082, 1735117933, 0);
INSERT INTO `nl_menu` VALUES (6, '管理员管理', 'grommet-icons:user-admin', 'SystemUser', '/system/user', '/system/admin/index', '', 1, 0, 1, '', 0, 0, '', 5, 0, '', 1734486178, 0, 0);
INSERT INTO `nl_menu` VALUES (7, '角色管理', 'carbon:user-role', 'SystemRole', '/system/role', '/system/role/index', '', 1, 0, 1, '', 0, 0, '', 5, 1, '', 1734486291, 1734489429, 0);
INSERT INTO `nl_menu` VALUES (8, '菜单管理', 'line-md:menu', 'SystemMenu', '/system/menu', '/system/menu/index', '', 1, 0, 1, '', 0, 0, '', 5, 2, '', 1734486345, 0, 0);
INSERT INTO `nl_menu` VALUES (9, '代码生成', 'fluent-color:code-20', 'CodeGeneration', '/code-generation', '/code-generation/index', '', 1, 0, 1, '', 0, 0, '', 0, 99999999, '', 0, 0, 0);
INSERT INTO `nl_menu` VALUES (10, '数据库管理', 'material-symbols:database', 'SystemDatabase', '/system/database', '/system/database/index', '', 1, 0, 1, '', 0, 0, '', 5, 3, '', 1734486345, 0, 0);
INSERT INTO `nl_menu` VALUES (11, '系统配置', 'lucide:settings-2', 'SystemConfig', '/system/config', '/system/config/index', '', 1, 0, 1, '', 0, 0, '', 5, 50, '', 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_role
-- ----------------------------
DROP TABLE IF EXISTS `nl_role`;
CREATE TABLE `nl_role`  (
                            `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
                            `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色名称',
                            `value` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '角色值',
                            `pid` int NOT NULL DEFAULT 0 COMMENT '上级角色',
                            `desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '角色说明',
                            `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                            `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                            `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间',
                            PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '角色表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_role
-- ----------------------------
INSERT INTO `nl_role` VALUES (1, '超级管理员', 'admin', 0, '', 0, 0, 0);

-- ----------------------------
-- Table structure for nl_role_menu_relations
-- ----------------------------
DROP TABLE IF EXISTS `nl_role_menu_relations`;
CREATE TABLE `nl_role_menu_relations`  (
                                           `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                           `role_id` int NOT NULL DEFAULT 0 COMMENT '角色ID',
                                           `menu_id` int NOT NULL DEFAULT 0 COMMENT '菜单ID',
                                           `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                           PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '角色权限绑定表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Records of nl_role_menu_relations
-- ----------------------------
INSERT INTO `nl_role_menu_relations` VALUES (1, 1, 1, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (2, 1, 2, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (3, 1, 3, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (4, 1, 4, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (5, 1, 5, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (6, 1, 6, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (7, 1, 7, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (8, 1, 8, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (9, 1, 9, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (10, 1, 10, 1747033198);
INSERT INTO `nl_role_menu_relations` VALUES (11, 1, 11, 1786329600);

-- ----------------------------
-- Table structure for nl_system_config
-- ----------------------------
DROP TABLE IF EXISTS `nl_system_config`;
CREATE TABLE `nl_system_config` (
                                    `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                    `key` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '配置键，全局唯一',
                                    `value` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '配置值（可 JSON 字符串）',
                                    `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '备注说明',
                                    `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                    `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                    `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                    PRIMARY KEY (`id`) USING BTREE,
                                    UNIQUE INDEX `uk_key`(`key` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统配置' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_system_config` (`key`, `value`, `remark`, `created_at`, `updated_at`, `deleted_at`) VALUES
                                                                                                        ('ai_active_provider', 'deepseek', '当前启用的 AI 平台编码：spark/deepseek', 1786329600, 0, 0),
                                                                                                        ('ai_active_model', 'deepseek-chat', '当前启用的模型编码', 1786329600, 0, 0),
                                                                                                        ('ai_active_api_key_id', '2', '当前启用的 API 密钥 ID，0 表示按平台默认密钥', 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_ai_platform
-- ----------------------------
DROP TABLE IF EXISTS `nl_ai_platform`;
CREATE TABLE `nl_ai_platform` (
                                  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                  `code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '平台编码：spark/deepseek',
                                  `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '平台名称',
                                  `api_url` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Chat Completions 接口地址',
                                  `logo` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Logo URL（卡片展示）',
                                  `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '平台说明',
                                  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用0禁用',
                                  `sort` int NOT NULL DEFAULT 0 COMMENT '排序，越大越靠前',
                                  `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                  `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                  `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                  PRIMARY KEY (`id`) USING BTREE,
                                  UNIQUE INDEX `uk_code`(`code` ASC) USING BTREE,
                                  INDEX `idx_status_sort`(`status` ASC, `sort` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'AI平台' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_ai_platform` VALUES
                                 (1, 'spark', '讯飞星火', 'https://spark-api-open.xf-yun.com/v1/chat/completions', 'https://p9.itc.cn/q_70/images03/20230713/28e961f4b8274101bcaddce110828f5c.png', '讯飞星火 OpenAPI（OpenAI 兼容）', 1, 100, 1786329600, 0, 0),
                                 (2, 'deepseek', 'DeepSeek', 'https://api.deepseek.com/v1/chat/completions', 'https://ts3.tc.mm.bing.net/th/id/OIP-C.xc2137qQttRyKpPwq3ooRwAAAA?w=108&h=108&c=1&bgcl=84b7ac&r=0&o=7&pid=ImgRC&rm=3', 'DeepSeek Chat Completions API', 1, 90, 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_ai_model
-- ----------------------------
DROP TABLE IF EXISTS `nl_ai_model`;
CREATE TABLE `nl_ai_model` (
                               `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                               `platform_id` int NOT NULL DEFAULT 0 COMMENT 'AI平台ID',
                               `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '模型编码（调用API用，如 lite / deepseek-chat）',
                               `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '展示名称',
                               `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '模型说明',
                               `is_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否平台默认模型 0否1是',
                               `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用0禁用',
                               `sort` int NOT NULL DEFAULT 0 COMMENT '排序，越大越靠前',
                               `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                               `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                               `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                               PRIMARY KEY (`id`) USING BTREE,
                               INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
                               INDEX `idx_platform_code`(`platform_id` ASC, `code` ASC) USING BTREE,
                               INDEX `idx_status_sort`(`status` ASC, `sort` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'AI厂商模型' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_ai_model` VALUES
                              (1, 1, 'lite', 'lite', '讯飞星火 默认模型', 1, 1, 100, 1786329600, 0, 0),
                              (2, 2, 'deepseek-chat', 'deepseek-chat', 'DeepSeek 默认模型', 1, 1, 100, 1786329600, 0, 0),
                              (4, 2, 'deepseek-reasoner', 'DeepSeek Reasoner', '推理模型', 0, 1, 80, 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_ai_api_key
-- ----------------------------
DROP TABLE IF EXISTS `nl_ai_api_key`;
CREATE TABLE `nl_ai_api_key` (
                                 `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                 `platform_id` int NOT NULL DEFAULT 0 COMMENT 'AI平台ID',
                                 `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '密钥别名',
                                 `api_key` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'API密钥（库内AES加密，前缀 nl_ase_256_）',
                                 `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '备注',
                                 `is_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否平台默认密钥 0否1是',
                                 `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用0禁用',
                                 `sort` int NOT NULL DEFAULT 0 COMMENT '排序，越大越靠前',
                                 `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                 `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                 `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                 PRIMARY KEY (`id`) USING BTREE,
                                 INDEX `idx_platform_id`(`platform_id` ASC) USING BTREE,
                                 INDEX `idx_status_sort`(`status` ASC, `sort` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'AI平台API密钥' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_ai_api_key` VALUES
                                (1, 1, '李琦-免费', 'nl_ase_256_3Oy8Dxp82N0PgU2rXLrhVADcfwkqG+rzTwWboUpdYnX9Sd6acEtx95BAXVehSaGHWiDq7Zgr/SRcjHDNhPfg4Q==', '李琦-免费，测试key', 1, 1, 0, 1786329600, 0, 0),
                                (2, 2, 'DeepSeek-v4', 'nl_ase_256_K5ycIstKd4nalXpGqN79TggP7t+NywXffr+gN8uZcLh1T09CWI4nLPZkAgosrUoDaDCOmgIthhLvQsqHxWLtQA==', 'DeepSeek-v4', 1, 1, 0, 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_ai_generation
-- ----------------------------
DROP TABLE IF EXISTS `nl_ai_generation`;
CREATE TABLE `nl_ai_generation` (
                                    `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                    `admin_id` int NOT NULL DEFAULT 0 COMMENT '操作管理员ID',
                                    `scene` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '场景：code_generation/requirement_prompt',
                                    `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '展示名称（如模块名）',
                                    `provider` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'AI供应商：spark/deepseek',
                                    `model` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '模型名',
                                    `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0进行中1成功2失败',
                                    `api_key_id` int NOT NULL DEFAULT 0 COMMENT 'nl_ai_api_key.id，env回落为0',
                                    `prompt_tokens` int NOT NULL DEFAULT 0 COMMENT '输入token数',
                                    `completion_tokens` int NOT NULL DEFAULT 0 COMMENT '输出token数',
                                    `total_tokens` int NOT NULL DEFAULT 0 COMMENT '总token数',
                                    `usage_json` json NULL COMMENT '完整usage原始对象',
                                    `started_at` int NOT NULL DEFAULT 0 COMMENT '开始时间戳',
                                    `finished_at` int NOT NULL DEFAULT 0 COMMENT '结束时间戳',
                                    `duration_ms` int NOT NULL DEFAULT 0 COMMENT '耗时毫秒',
                                    `error_msg` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '失败原因摘要',
                                    `input_snapshot` json NULL COMMENT '输入快照（模块名/描述/pid等）',
                                    `result_json` json NULL COMMENT '结构化结果 JSON',
                                    `raw_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '模型原始响应文本',
                                    `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                    `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                    `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                    PRIMARY KEY (`id`) USING BTREE,
                                    INDEX `idx_admin_scene`(`admin_id` ASC, `scene` ASC, `deleted_at` ASC) USING BTREE,
                                    INDEX `idx_status_created`(`status` ASC, `created_at` ASC) USING BTREE,
                                    INDEX `idx_provider_model_created`(`provider` ASC, `model` ASC, `created_at` ASC) USING BTREE,
                                    INDEX `idx_api_key_created`(`api_key_id` ASC, `created_at` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'AI生成历史' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for nl_oss_config
-- ----------------------------
DROP TABLE IF EXISTS `nl_oss_config`;
CREATE TABLE `nl_oss_config` (
                                 `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                 `driver` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'local' COMMENT '驱动：local/aliyun/qcloud/qiniu/huawei/aws/minio/baidu',
                                 `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '配置别名',
                                 `access_key` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'AccessKey（库内AES加密）',
                                 `secret_key` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'SecretKey（库内AES加密）',
                                 `endpoint` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Endpoint/服务地址',
                                 `region` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '地域，如 ap-guangzhou',
                                 `bucket` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'Bucket 名称',
                                 `domain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '对外访问域名（含协议）',
                                 `path_prefix` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '对象路径前缀',
                                 `extra_json` json NULL COMMENT '扩展配置 JSON',
                                 `is_active` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否当前启用 0否1是（全局仅一套）',
                                 `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用0禁用',
                                 `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '备注',
                                 `sort` int NOT NULL DEFAULT 0 COMMENT '排序，越大越靠前',
                                 `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                 `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                 `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                 PRIMARY KEY (`id`) USING BTREE,
                                 INDEX `idx_driver_status`(`driver` ASC, `status` ASC) USING BTREE,
                                 INDEX `idx_is_active`(`is_active` ASC, `deleted_at` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'OSS存储配置' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_oss_config` VALUES
                                (1, 'local', '本地存储', '', '', '', '', '', '', 'uploads', NULL, 1, 1, '默认本地磁盘，文件落到 storage/app', 100, 1786329600, 0, 0),
                                (2, 'aliyun', '阿里云 OSS', '', '', 'oss-cn-hangzhou.aliyuncs.com', 'cn-hangzhou', '', '', 'uploads', NULL, 0, 1, '请填写 AccessKey/Secret、Bucket、访问域名；Endpoint 可按地域修改', 90, 1786329600, 0, 0),
                                (3, 'qcloud', '腾讯云 COS', '', '', '', 'ap-guangzhou', '', '', 'uploads', NULL, 0, 1, '请填写 SecretId/SecretKey、Bucket、Region、访问域名', 80, 1786329600, 0, 0),
                                (4, 'qiniu', '七牛云 Kodo', '', '', '', '', '', '', 'uploads', NULL, 0, 1, '请填写 AccessKey/SecretKey、Bucket、外链域名（含协议）', 70, 1786329600, 0, 0),
                                (5, 'huawei', '华为云 OBS', '', '', 'https://obs.cn-north-4.myhuaweicloud.com', 'cn-north-4', '', '', 'uploads', NULL, 0, 1, '请填写 AK/SK、Bucket、Endpoint、访问域名', 60, 1786329600, 0, 0),
                                (6, 'aws', 'AWS S3', '', '', 'https://s3.amazonaws.com', 'us-east-1', '', '', 'uploads', NULL, 0, 1, '请填写 AccessKey/Secret、Bucket、Region、访问域名', 50, 1786329600, 0, 0),
                                (7, 'minio', 'MinIO', '', '', 'http://127.0.0.1:9000', 'us-east-1', '', '', 'uploads', NULL, 0, 1, '私有化 S3 兼容；请填写 Key、Bucket、Endpoint', 40, 1786329600, 0, 0),
                                (8, 'baidu', '百度云 BOS', '', '', 'https://bj.bcebos.com', 'bj', '', '', 'uploads', NULL, 0, 1, '请填写 AccessKey/SecretKey、Bucket、Endpoint、访问域名', 30, 1786329600, 0, 0);

INSERT INTO `nl_system_config` (`key`, `value`, `remark`, `created_at`, `updated_at`, `deleted_at`) VALUES
    ('oss_active_config_id', '1', '当前启用的 OSS 配置 ID', 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_api_endpoint
-- ----------------------------
DROP TABLE IF EXISTS `nl_api_endpoint`;
CREATE TABLE `nl_api_endpoint` (
                                   `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                   `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '接口路径，如 admin/list（不含前缀 /api/）',
                                   `method` tinyint(1) NOT NULL DEFAULT 0 COMMENT '请求方式 0ANY 1GET 2POST',
                                   `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作名',
                                   `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '接口说明',
                                   `controller` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '所属控制器',
                                   `is_log` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否记录操作日志 0否1是',
                                   `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1启用0禁用',
                                   `created_at` int NOT NULL DEFAULT 0 COMMENT '创建时间',
                                   `updated_at` int NOT NULL DEFAULT 0 COMMENT '更新时间',
                                   `deleted_at` int NOT NULL DEFAULT 0 COMMENT '删除时间，0表示未删除',
                                   PRIMARY KEY (`id`) USING BTREE,
                                   UNIQUE INDEX `uk_url_method`(`url` ASC, `method` ASC) USING BTREE,
                                   INDEX `idx_is_log`(`is_log` ASC, `status` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '接口注册表' ROW_FORMAT = DYNAMIC;

INSERT INTO `nl_api_endpoint` (`url`, `method`, `name`, `description`, `controller`, `is_log`, `status`, `created_at`, `updated_at`, `deleted_at`) VALUES
                                                                                                                                                       ('login', 2, '登录', '账号密码登录', 'LoginController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('register', 2, '注册', '注册管理员账号', 'LoginController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('logout', 0, '退出登录', '退出登录', 'LoginController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('codes', 0, '权限码', '获取权限码（登录前）', 'LoginController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/list', 1, '管理员列表', '分页查询管理员', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/option', 1, '管理员下拉', '管理员下拉选项', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/detail', 1, '管理员详情', '管理员详情', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/create', 2, '创建管理员', '新增管理员', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/update', 2, '更新管理员', '编辑管理员', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/delete', 2, '删除管理员', '删除管理员', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/change-password', 2, '修改密码', '当前用户修改密码', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/reset-password', 2, '重置密码', '管理员重置他人密码', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/my-info', 1, '我的信息', '获取当前登录用户信息', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/update-profile', 2, '更新个人资料', '个人中心编辑资料/头像', 'AdminController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/menu', 1, '我的菜单', '按角色获取菜单树', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/codes', 1, '我的权限码', '获取当前用户权限码', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/login-log', 1, '我的登录日志', '个人中心登录日志', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('admin/op-log', 1, '我的操作日志', '个人中心操作日志', 'AdminController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/list', 1, '角色列表', '分页查询角色', 'RoleController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/option', 1, '角色下拉', '角色下拉选项', 'RoleController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/detail', 1, '角色详情', '角色详情', 'RoleController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/create', 2, '创建角色', '新增角色', 'RoleController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/update', 2, '更新角色', '编辑角色', 'RoleController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/delete', 2, '删除角色', '删除角色', 'RoleController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/get-menu-ids-by-role-ids', 1, '角色菜单ID', '按角色获取已绑菜单', 'RoleController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('role/save-role-menu', 2, '保存角色菜单', '绑定角色菜单权限', 'RoleController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/list', 1, '菜单列表', '分页查询菜单', 'MenuController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/option', 1, '菜单下拉', '菜单下拉选项', 'MenuController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/detail', 1, '菜单详情', '菜单详情', 'MenuController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/create', 2, '创建菜单', '新增菜单', 'MenuController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/update', 2, '更新菜单', '编辑菜单', 'MenuController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/delete', 2, '删除菜单', '删除菜单', 'MenuController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('menu/tree-option', 1, '菜单树', '菜单树形选项', 'MenuController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('upload/image', 2, '上传图片', '上传图片文件', 'UploadController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('upload/video', 2, '上传视频', '上传视频文件', 'UploadController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/list-tables', 1, '库表列表', '列出数据库表', 'DatabaseController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/get-table-info', 1, '表结构', '获取表结构信息', 'DatabaseController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/get-table-data', 2, '表数据查询', '查询表数据', 'DatabaseController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/update-table-data', 2, '更新表数据', '修改表行数据', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/delete-table-data', 2, '删除表数据', '删除表行数据', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/batch-delete-table-data', 2, '批量删除表数据', '批量删除表行', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/insert-table-data', 2, '插入表数据', '新增表行数据', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/update-table-comment', 2, '更新表注释', '修改表注释', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/update-column-comment', 2, '更新字段注释', '修改字段注释', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/add-index', 2, '添加索引', '创建表索引', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/drop-index', 2, '删除索引', '删除表索引', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/update-table-structure', 2, '改表结构', '修改表结构', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/execute-sql-query', 2, '执行SQL', '执行自定义 SQL', 'DatabaseController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('database/get-change-log', 1, '库变更日志', '数据库变更记录', 'DatabaseController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/runtime-options', 1, 'AI运行时选项', 'AI平台/模型/密钥选项', 'AiConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/save-runtime', 2, '保存AI运行时', '保存默认AI组合', 'AiConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/key-list', 1, 'AI密钥列表', 'API Key 卡片列表', 'AiConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/platform-option', 1, 'AI平台下拉', 'AI平台选项', 'AiConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/create-key', 2, '创建AI密钥', '新增API Key', 'AiConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/update-key', 2, '更新AI密钥', '编辑API Key', 'AiConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/delete-key', 2, '删除AI密钥', '删除API Key', 'AiConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/generation-list', 1, 'AI生成列表', 'AI生成历史列表', 'AiConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('ai-config/generation-detail', 1, 'AI生成详情', 'AI生成历史详情', 'AiConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/generation', 2, '代码生成', '按模块生成代码', 'CodeGenerationController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/batch-generation', 2, '批量代码生成', '批量生成代码', 'CodeGenerationController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/download', 0, '下载代码包', '下载生成结果', 'CodeGenerationController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/download-info', 0, '下载信息', '代码包下载信息', 'CodeGenerationController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/get-tables', 1, '代码生成表列表', '可选数据表', 'CodeGenerationController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/get-table-structure', 1, '代码生成表结构', '表结构供生成', 'CodeGenerationController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/generate-from-table', 2, '从表生成', '按表结构生成代码', 'CodeGenerationController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/ai-generate', 2, 'AI代码生成', 'AI辅助代码生成', 'CodeGenerationController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('code/ai-requirement-prompt', 2, 'AI需求提示词', '生成需求提示词', 'CodeGenerationController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/driver-options', 1, 'OSS驱动选项', '可选存储驱动列表', 'OssConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/runtime-options', 1, 'OSS运行时选项', '配置卡片+当前启用', 'OssConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/save-runtime', 2, '启用OSS配置', '切换当前存储驱动', 'OssConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/list', 1, 'OSS配置列表', '存储配置列表', 'OssConfigController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/create', 2, '创建OSS配置', '新增存储配置', 'OssConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/update', 2, '更新OSS配置', '编辑存储配置', 'OssConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('oss-config/delete', 2, '删除OSS配置', '删除存储配置', 'OssConfigController', 1, 1, 1786329600, 0, 0),
                                                                                                                                                       ('api-endpoint/list', 1, '接口列表', '接口注册表分页', 'ApiEndpointController', 0, 1, 1786329600, 0, 0),
                                                                                                                                                       ('api-endpoint/update', 2, '更新接口', '编辑接口说明/是否记日志', 'ApiEndpointController', 1, 1, 1786329600, 0, 0);

-- ----------------------------
-- Table structure for nl_login_log
-- ----------------------------
DROP TABLE IF EXISTS `nl_login_log`;
CREATE TABLE `nl_login_log` (
                                `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
                                `user_id` int NOT NULL DEFAULT 0 COMMENT '管理员ID，失败时可能为0',
                                `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '登录账号/手机号',
                                `nick_name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '昵称快照',
                                `ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '登录IP',
                                `equipment` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '操作系统',
                                `browser` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '浏览器',
                                `status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0成功1失败',
                                `message` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '结果说明',
                                `created_at` int NOT NULL DEFAULT 0 COMMENT '登录时间',
                                PRIMARY KEY (`id`) USING BTREE,
                                INDEX `idx_user_created`(`user_id` ASC, `created_at` ASC) USING BTREE,
                                INDEX `idx_created_at`(`created_at` ASC) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '登录日志' ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;
