From b13d584f5719ab81d1f55ba4346a229c82691889 Mon Sep 17 00:00:00 2001 From: expressgy Date: Fri, 21 Mar 2025 18:02:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9ESwagger=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加Swagger插件以支持API文档生成,并优化数据库配置和日志记录。同时,更新了SQL表结构和迁移文件,确保数据库的一致性和完整性。 --- SQL/0000_skinny_bloodaxe.sql | 216 +++ SQL/meta/0000_snapshot.json | 1514 ++++++++++++++++++++++ SQL/meta/_journal.json | 13 + SQL/relations.ts | 3 + SQL/schema.ts | 242 ++++ config/index.js | 10 + migrations/0000_wandering_marvel_boy.sql | 7 - migrations/meta/0000_snapshot.json | 59 - migrations/meta/_journal.json | 13 - package-lock.json | 608 ++++++++- package.json | 2 + rbac_system.sql | 137 -- src/plugins/database/index.js | 3 + src/plugins/index.js | 5 +- src/plugins/swagger/index.js | 25 + src/routes/index.js | 44 + src/schema/test.schema.js | 31 + src/services/test.service.js | 6 + src/utils/logger.js | 1 + yuheng.sql | 249 ++-- 20 files changed, 2878 insertions(+), 310 deletions(-) create mode 100644 SQL/0000_skinny_bloodaxe.sql create mode 100644 SQL/meta/0000_snapshot.json create mode 100644 SQL/meta/_journal.json create mode 100644 SQL/relations.ts create mode 100644 SQL/schema.ts delete mode 100644 migrations/0000_wandering_marvel_boy.sql delete mode 100644 migrations/meta/0000_snapshot.json delete mode 100644 migrations/meta/_journal.json delete mode 100644 rbac_system.sql create mode 100644 src/plugins/swagger/index.js create mode 100644 src/schema/test.schema.js create mode 100644 src/services/test.service.js diff --git a/SQL/0000_skinny_bloodaxe.sql b/SQL/0000_skinny_bloodaxe.sql new file mode 100644 index 0000000..2bd8f0c --- /dev/null +++ b/SQL/0000_skinny_bloodaxe.sql @@ -0,0 +1,216 @@ +-- Current sql file was generated after introspecting the database +-- If you want to run this migration please uncomment this code before executing migrations +/* +CREATE TABLE `sys_dict` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `version` int NOT NULL DEFAULT 0, + `pid` bigint NOT NULL, + `module` tinyint, + `dict_key` varchar(255), + `value` varchar(255), + `description` varchar(255), + `sort` int NOT NULL DEFAULT 0, + `status` int NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_dict_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_dict_key` UNIQUE(`dict_key`,`pid`) +); +--> statement-breakpoint +CREATE TABLE `sys_organization` ( + `org_id` bigint AUTO_INCREMENT NOT NULL, + `pid` bigint NOT NULL DEFAULT 0, + `org_name` varchar(255), + `org_code` varchar(128), + `org_type` int NOT NULL, + `description` varchar(255), + `sort` int NOT NULL DEFAULT 0, + `status` int NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_organization_org_id` PRIMARY KEY(`org_id`), + CONSTRAINT `uniq_org_code` UNIQUE(`org_code`,`pid`), + CONSTRAINT `uniq_org_name` UNIQUE(`org_name`,`pid`) +); +--> statement-breakpoint +CREATE TABLE `sys_organization_manager` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `version` int NOT NULL DEFAULT 0, + `org_id` bigint NOT NULL, + `user_id` bigint NOT NULL, + `rank` int NOT NULL, + `description` varchar(255), + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_organization_manager_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_org_user` UNIQUE(`org_id`,`user_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_permission` ( + `perm_id` bigint AUTO_INCREMENT NOT NULL, + `pid` bigint NOT NULL DEFAULT 0, + `perm_name` varchar(255) NOT NULL, + `perm_key` varchar(255) NOT NULL, + `url` varchar(255), + `avatar_url` varchar(255), + `description` varchar(255), + `perm_type` int NOT NULL, + `is_visible` int NOT NULL DEFAULT 0, + `version` int NOT NULL DEFAULT 0, + `sort` int NOT NULL DEFAULT 0, + `status` int NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_permission_perm_id` PRIMARY KEY(`perm_id`), + CONSTRAINT `uniq_pid_name` UNIQUE(`perm_name`,`pid`), + CONSTRAINT `uniq_perm_key` UNIQUE(`perm_key`) +); +--> statement-breakpoint +CREATE TABLE `sys_re_role_permission` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `role_id` bigint NOT NULL, + `perm_id` bigint NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_re_role_permission_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_perm_role` UNIQUE(`role_id`,`perm_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_re_user_organization` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `user_id` bigint NOT NULL, + `org_id` bigint NOT NULL, + `version` int NOT NULL DEFAULT 0, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_re_user_organization_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_user_org` UNIQUE(`user_id`,`org_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_re_user_role` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `user_id` bigint NOT NULL, + `role_id` bigint NOT NULL, + `version` int NOT NULL DEFAULT 0, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_re_user_role_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_user_role` UNIQUE(`user_id`,`role_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_role` ( + `role_id` bigint AUTO_INCREMENT NOT NULL, + `pid` bigint NOT NULL, + `role_name` varchar(255) NOT NULL, + `role_key` varchar(255) NOT NULL, + `description` varchar(255), + `status` int NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_role_role_id` PRIMARY KEY(`role_id`), + CONSTRAINT `uniq_role_pid` UNIQUE(`role_name`,`pid`) +); +--> statement-breakpoint +CREATE TABLE `sys_user` ( + `user_id` bigint NOT NULL, + `pid` bigint NOT NULL, + `username` varchar(255) NOT NULL, + `email` varchar(255) NOT NULL, + `phone` varchar(255), + `avatar_url` varchar(255), + `user_type` tinyint, + `status` tinyint NOT NULL DEFAULT 0, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_user_user_id` PRIMARY KEY(`user_id`), + CONSTRAINT `uniq_username` UNIQUE(`username`), + CONSTRAINT `uniq_email` UNIQUE(`email`) +); +--> statement-breakpoint +CREATE TABLE `sys_user_auth` ( + `user_id` bigint NOT NULL, + `password_hash` varchar(255) NOT NULL, + `password_modified` datetime NOT NULL, + `password_expire` datetime, + CONSTRAINT `sys_user_auth_user_id` PRIMARY KEY(`user_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_user_auth_history` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `user_id` bigint NOT NULL, + `password_hash` varchar(255) NOT NULL, + `modified_at` varchar(255) NOT NULL, + CONSTRAINT `sys_user_auth_history_id` PRIMARY KEY(`id`) +); +--> statement-breakpoint +CREATE TABLE `sys_user_field_definition` ( + `field_id` bigint AUTO_INCREMENT NOT NULL, + `version` int NOT NULL DEFAULT 0, + `field_name` varchar(255) NOT NULL, + `field_key` varchar(255) NOT NULL, + `field_type` tinyint NOT NULL, + `dict_module` int, + `is_required` tinyint NOT NULL DEFAULT 0, + `limit` int, + `description` varchar(255), + `default_value` varchar(255), + `default_options` varchar(255), + `sort` int NOT NULL DEFAULT 0, + `status` int NOT NULL, + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_user_field_definition_field_id` PRIMARY KEY(`field_id`), + CONSTRAINT `uniq_field_name` UNIQUE(`field_name`), + CONSTRAINT `uniq_field_key` UNIQUE(`field_key`) +); +--> statement-breakpoint +CREATE TABLE `sys_user_field_value` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `user_id` bigint NOT NULL, + `field_id` int NOT NULL, + `value` varchar(4096), + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_user_field_value_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_user_field` UNIQUE(`user_id`,`field_id`) +); +--> statement-breakpoint +CREATE TABLE `sys_user_profile` ( + `id` bigint AUTO_INCREMENT NOT NULL, + `version` int NOT NULL DEFAULT 0, + `name` varchar(32) NOT NULL, + `profile_key` varchar(255) NOT NULL, + `description` varchar(255), + `content` varchar(255), + `created_by` bigint NOT NULL, + `updated_by` bigint NOT NULL, + `created_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + `updated_at` datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + CONSTRAINT `sys_user_profile_id` PRIMARY KEY(`id`), + CONSTRAINT `uniq_name` UNIQUE(`name`), + CONSTRAINT `uniq_profile_key` UNIQUE(`profile_key`) +); + +*/ \ No newline at end of file diff --git a/SQL/meta/0000_snapshot.json b/SQL/meta/0000_snapshot.json new file mode 100644 index 0000000..b4a223f --- /dev/null +++ b/SQL/meta/0000_snapshot.json @@ -0,0 +1,1514 @@ +{ + "id": "00000000-0000-0000-0000-000000000000", + "prevId": "", + "version": "5", + "dialect": "mysql", + "tables": { + "sys_dict": { + "name": "sys_dict", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "pid": { + "autoincrement": false, + "name": "pid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "module": { + "autoincrement": false, + "name": "module", + "type": "tinyint", + "primaryKey": false, + "notNull": false + }, + "dict_key": { + "autoincrement": false, + "name": "dict_key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "value": { + "autoincrement": false, + "name": "value", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "sort": { + "default": 0, + "autoincrement": false, + "name": "sort", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "status": { + "autoincrement": false, + "name": "status", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_dict_id": { + "name": "sys_dict_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_dict_key": { + "name": "uniq_dict_key", + "columns": [ + "dict_key", + "pid" + ] + } + }, + "checkConstraint": {} + }, + "sys_organization": { + "name": "sys_organization", + "columns": { + "org_id": { + "autoincrement": true, + "name": "org_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "pid": { + "default": 0, + "autoincrement": false, + "name": "pid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "org_name": { + "autoincrement": false, + "name": "org_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "org_code": { + "autoincrement": false, + "name": "org_code", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "org_type": { + "autoincrement": false, + "name": "org_type", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "sort": { + "default": 0, + "autoincrement": false, + "name": "sort", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "status": { + "autoincrement": false, + "name": "status", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_organization_org_id": { + "name": "sys_organization_org_id", + "columns": [ + "org_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_org_code": { + "name": "uniq_org_code", + "columns": [ + "org_code", + "pid" + ] + }, + "uniq_org_name": { + "name": "uniq_org_name", + "columns": [ + "org_name", + "pid" + ] + } + }, + "checkConstraint": {} + }, + "sys_organization_manager": { + "name": "sys_organization_manager", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "autoincrement": false, + "name": "org_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "rank": { + "autoincrement": false, + "name": "rank", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_organization_manager_id": { + "name": "sys_organization_manager_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_org_user": { + "name": "uniq_org_user", + "columns": [ + "org_id", + "user_id" + ] + } + }, + "checkConstraint": {} + }, + "sys_permission": { + "name": "sys_permission", + "columns": { + "perm_id": { + "autoincrement": true, + "name": "perm_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "pid": { + "default": 0, + "autoincrement": false, + "name": "pid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "perm_name": { + "autoincrement": false, + "name": "perm_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "perm_key": { + "autoincrement": false, + "name": "perm_key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "url": { + "autoincrement": false, + "name": "url", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "avatar_url": { + "autoincrement": false, + "name": "avatar_url", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "perm_type": { + "autoincrement": false, + "name": "perm_type", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "is_visible": { + "default": 0, + "autoincrement": false, + "name": "is_visible", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "sort": { + "default": 0, + "autoincrement": false, + "name": "sort", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "status": { + "autoincrement": false, + "name": "status", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_permission_perm_id": { + "name": "sys_permission_perm_id", + "columns": [ + "perm_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_pid_name": { + "name": "uniq_pid_name", + "columns": [ + "perm_name", + "pid" + ] + }, + "uniq_perm_key": { + "name": "uniq_perm_key", + "columns": [ + "perm_key" + ] + } + }, + "checkConstraint": {} + }, + "sys_re_role_permission": { + "name": "sys_re_role_permission", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "autoincrement": false, + "name": "role_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "perm_id": { + "autoincrement": false, + "name": "perm_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_re_role_permission_id": { + "name": "sys_re_role_permission_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_perm_role": { + "name": "uniq_perm_role", + "columns": [ + "role_id", + "perm_id" + ] + } + }, + "checkConstraint": {} + }, + "sys_re_user_organization": { + "name": "sys_re_user_organization", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "org_id": { + "autoincrement": false, + "name": "org_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_re_user_organization_id": { + "name": "sys_re_user_organization_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_user_org": { + "name": "uniq_user_org", + "columns": [ + "user_id", + "org_id" + ] + } + }, + "checkConstraint": {} + }, + "sys_re_user_role": { + "name": "sys_re_user_role", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "autoincrement": false, + "name": "role_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_re_user_role_id": { + "name": "sys_re_user_role_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_user_role": { + "name": "uniq_user_role", + "columns": [ + "user_id", + "role_id" + ] + } + }, + "checkConstraint": {} + }, + "sys_role": { + "name": "sys_role", + "columns": { + "role_id": { + "autoincrement": true, + "name": "role_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "pid": { + "autoincrement": false, + "name": "pid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "role_name": { + "autoincrement": false, + "name": "role_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "role_key": { + "autoincrement": false, + "name": "role_key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "status": { + "autoincrement": false, + "name": "status", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_role_role_id": { + "name": "sys_role_role_id", + "columns": [ + "role_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_role_pid": { + "name": "uniq_role_pid", + "columns": [ + "role_name", + "pid" + ] + } + }, + "checkConstraint": {} + }, + "sys_user": { + "name": "sys_user", + "columns": { + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "pid": { + "autoincrement": false, + "name": "pid", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "username": { + "autoincrement": false, + "name": "username", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email": { + "autoincrement": false, + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "phone": { + "autoincrement": false, + "name": "phone", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "avatar_url": { + "autoincrement": false, + "name": "avatar_url", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "user_type": { + "autoincrement": false, + "name": "user_type", + "type": "tinyint", + "primaryKey": false, + "notNull": false + }, + "status": { + "default": 0, + "autoincrement": false, + "name": "status", + "type": "tinyint", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_user_user_id": { + "name": "sys_user_user_id", + "columns": [ + "user_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_username": { + "name": "uniq_username", + "columns": [ + "username" + ] + }, + "uniq_email": { + "name": "uniq_email", + "columns": [ + "email" + ] + } + }, + "checkConstraint": {} + }, + "sys_user_auth": { + "name": "sys_user_auth", + "columns": { + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "autoincrement": false, + "name": "password_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "password_modified": { + "autoincrement": false, + "name": "password_modified", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "password_expire": { + "autoincrement": false, + "name": "password_expire", + "type": "datetime", + "primaryKey": false, + "notNull": false + } + }, + "compositePrimaryKeys": { + "sys_user_auth_user_id": { + "name": "sys_user_auth_user_id", + "columns": [ + "user_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "sys_user_auth_history": { + "name": "sys_user_auth_history", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "password_hash": { + "autoincrement": false, + "name": "password_hash", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "modified_at": { + "autoincrement": false, + "name": "modified_at", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_user_auth_history_id": { + "name": "sys_user_auth_history_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": {}, + "checkConstraint": {} + }, + "sys_user_field_definition": { + "name": "sys_user_field_definition", + "columns": { + "field_id": { + "autoincrement": true, + "name": "field_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "field_name": { + "autoincrement": false, + "name": "field_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "field_key": { + "autoincrement": false, + "name": "field_key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "field_type": { + "autoincrement": false, + "name": "field_type", + "type": "tinyint", + "primaryKey": false, + "notNull": true + }, + "dict_module": { + "autoincrement": false, + "name": "dict_module", + "type": "int", + "primaryKey": false, + "notNull": false + }, + "is_required": { + "default": 0, + "autoincrement": false, + "name": "is_required", + "type": "tinyint", + "primaryKey": false, + "notNull": true + }, + "limit": { + "autoincrement": false, + "name": "limit", + "type": "int", + "primaryKey": false, + "notNull": false + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "default_value": { + "autoincrement": false, + "name": "default_value", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "default_options": { + "autoincrement": false, + "name": "default_options", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "sort": { + "default": 0, + "autoincrement": false, + "name": "sort", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "status": { + "autoincrement": false, + "name": "status", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_user_field_definition_field_id": { + "name": "sys_user_field_definition_field_id", + "columns": [ + "field_id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_field_name": { + "name": "uniq_field_name", + "columns": [ + "field_name" + ] + }, + "uniq_field_key": { + "name": "uniq_field_key", + "columns": [ + "field_key" + ] + } + }, + "checkConstraint": {} + }, + "sys_user_field_value": { + "name": "sys_user_field_value", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "autoincrement": false, + "name": "user_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "field_id": { + "autoincrement": false, + "name": "field_id", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "value": { + "autoincrement": false, + "name": "value", + "type": "varchar(4096)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_user_field_value_id": { + "name": "sys_user_field_value_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_user_field": { + "name": "uniq_user_field", + "columns": [ + "user_id", + "field_id" + ] + } + }, + "checkConstraint": {} + }, + "sys_user_profile": { + "name": "sys_user_profile", + "columns": { + "id": { + "autoincrement": true, + "name": "id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "version": { + "default": 0, + "autoincrement": false, + "name": "version", + "type": "int", + "primaryKey": false, + "notNull": true + }, + "name": { + "autoincrement": false, + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "profile_key": { + "autoincrement": false, + "name": "profile_key", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "autoincrement": false, + "name": "description", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "content": { + "autoincrement": false, + "name": "content", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "autoincrement": false, + "name": "created_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "autoincrement": false, + "name": "updated_by", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "created_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "default": "(CURRENT_TIMESTAMP)", + "autoincrement": false, + "name": "updated_at", + "type": "datetime", + "primaryKey": false, + "notNull": true + } + }, + "compositePrimaryKeys": { + "sys_user_profile_id": { + "name": "sys_user_profile_id", + "columns": [ + "id" + ] + } + }, + "indexes": {}, + "foreignKeys": {}, + "uniqueConstraints": { + "uniq_name": { + "name": "uniq_name", + "columns": [ + "name" + ] + }, + "uniq_profile_key": { + "name": "uniq_profile_key", + "columns": [ + "profile_key" + ] + } + }, + "checkConstraint": {} + } + }, + "views": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "tables": { + "sys_dict": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_organization": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_organization_manager": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_permission": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_re_role_permission": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_re_user_organization": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_re_user_role": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_role": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_user": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_user_field_definition": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_user_field_value": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + }, + "sys_user_profile": { + "columns": { + "created_at": { + "isDefaultAnExpression": true + }, + "updated_at": { + "isDefaultAnExpression": true + } + } + } + }, + "indexes": {} + } +} \ No newline at end of file diff --git a/SQL/meta/_journal.json b/SQL/meta/_journal.json new file mode 100644 index 0000000..ff2a26c --- /dev/null +++ b/SQL/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "mysql", + "entries": [ + { + "idx": 0, + "version": "5", + "when": 1742546365192, + "tag": "0000_skinny_bloodaxe", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/SQL/relations.ts b/SQL/relations.ts new file mode 100644 index 0000000..80768e2 --- /dev/null +++ b/SQL/relations.ts @@ -0,0 +1,3 @@ +import { relations } from "drizzle-orm/relations"; +import { } from "./schema"; + diff --git a/SQL/schema.ts b/SQL/schema.ts new file mode 100644 index 0000000..73f4ba9 --- /dev/null +++ b/SQL/schema.ts @@ -0,0 +1,242 @@ +import { mysqlTable, mysqlSchema, AnyMySqlColumn, primaryKey, unique, bigint, int, tinyint, varchar, datetime } from "drizzle-orm/mysql-core" +import { sql } from "drizzle-orm" + +export const sysDict = mysqlTable("sys_dict", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + version: int().default(0).notNull(), + pid: bigint({ mode: "number" }).notNull(), + module: tinyint(), + dictKey: varchar("dict_key", { length: 255 }), + value: varchar({ length: 255 }), + description: varchar({ length: 255 }), + sort: int().default(0).notNull(), + status: int().notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_dict_id"}), + unique("uniq_dict_key").on(table.dictKey, table.pid), +]); + +export const sysOrganization = mysqlTable("sys_organization", { + orgId: bigint("org_id", { mode: "number" }).autoincrement().notNull(), + pid: bigint({ mode: "number" }).notNull(), + orgName: varchar("org_name", { length: 255 }), + orgCode: varchar("org_code", { length: 128 }), + orgType: int("org_type").notNull(), + description: varchar({ length: 255 }), + sort: int().default(0).notNull(), + status: int().notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.orgId], name: "sys_organization_org_id"}), + unique("uniq_org_code").on(table.orgCode, table.pid), + unique("uniq_org_name").on(table.orgName, table.pid), +]); + +export const sysOrganizationManager = mysqlTable("sys_organization_manager", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + version: int().default(0).notNull(), + orgId: bigint("org_id", { mode: "number" }).notNull(), + userId: bigint("user_id", { mode: "number" }).notNull(), + rank: int().notNull(), + description: varchar({ length: 255 }), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_organization_manager_id"}), + unique("uniq_org_user").on(table.orgId, table.userId), +]); + +export const sysPermission = mysqlTable("sys_permission", { + permId: bigint("perm_id", { mode: "number" }).autoincrement().notNull(), + pid: bigint({ mode: "number" }).notNull(), + permName: varchar("perm_name", { length: 255 }).notNull(), + permKey: varchar("perm_key", { length: 255 }).notNull(), + url: varchar({ length: 255 }), + avatarUrl: varchar("avatar_url", { length: 255 }), + description: varchar({ length: 255 }), + permType: int("perm_type").notNull(), + isVisible: int("is_visible").default(0).notNull(), + version: int().default(0).notNull(), + sort: int().default(0).notNull(), + status: int().notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.permId], name: "sys_permission_perm_id"}), + unique("uniq_pid_name").on(table.permName, table.pid), + unique("uniq_perm_key").on(table.permKey), +]); + +export const sysReRolePermission = mysqlTable("sys_re_role_permission", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + roleId: bigint("role_id", { mode: "number" }).notNull(), + permId: bigint("perm_id", { mode: "number" }).notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_re_role_permission_id"}), + unique("uniq_perm_role").on(table.roleId, table.permId), +]); + +export const sysReUserOrganization = mysqlTable("sys_re_user_organization", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + userId: bigint("user_id", { mode: "number" }).notNull(), + orgId: bigint("org_id", { mode: "number" }).notNull(), + version: int().default(0).notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_re_user_organization_id"}), + unique("uniq_user_org").on(table.userId, table.orgId), +]); + +export const sysReUserRole = mysqlTable("sys_re_user_role", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + userId: bigint("user_id", { mode: "number" }).notNull(), + roleId: bigint("role_id", { mode: "number" }).notNull(), + version: int().default(0).notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_re_user_role_id"}), + unique("uniq_user_role").on(table.userId, table.roleId), +]); + +export const sysRole = mysqlTable("sys_role", { + roleId: bigint("role_id", { mode: "number" }).autoincrement().notNull(), + pid: bigint({ mode: "number" }).notNull(), + roleName: varchar("role_name", { length: 255 }).notNull(), + roleKey: varchar("role_key", { length: 255 }).notNull(), + description: varchar({ length: 255 }), + status: int().notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.roleId], name: "sys_role_role_id"}), + unique("uniq_role_pid").on(table.roleName, table.pid), +]); + +export const sysUser = mysqlTable("sys_user", { + userId: bigint("user_id", { mode: "number" }).notNull(), + pid: bigint({ mode: "number" }).notNull(), + username: varchar({ length: 255 }).notNull(), + email: varchar({ length: 255 }).notNull(), + phone: varchar({ length: 255 }), + avatarUrl: varchar("avatar_url", { length: 255 }), + userType: tinyint("user_type"), + status: tinyint().default(0).notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.userId], name: "sys_user_user_id"}), + unique("uniq_username").on(table.username), + unique("uniq_email").on(table.email), +]); + +export const sysUserAuth = mysqlTable("sys_user_auth", { + userId: bigint("user_id", { mode: "number" }).notNull(), + passwordHash: varchar("password_hash", { length: 255 }).notNull(), + passwordModified: datetime("password_modified", { mode: 'string'}).notNull(), + passwordExpire: datetime("password_expire", { mode: 'string'}), +}, +(table) => [ + primaryKey({ columns: [table.userId], name: "sys_user_auth_user_id"}), +]); + +export const sysUserAuthHistory = mysqlTable("sys_user_auth_history", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + userId: bigint("user_id", { mode: "number" }).notNull(), + passwordHash: varchar("password_hash", { length: 255 }).notNull(), + modifiedAt: varchar("modified_at", { length: 255 }).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_user_auth_history_id"}), +]); + +export const sysUserFieldDefinition = mysqlTable("sys_user_field_definition", { + fieldId: bigint("field_id", { mode: "number" }).autoincrement().notNull(), + version: int().default(0).notNull(), + fieldName: varchar("field_name", { length: 255 }).notNull(), + fieldKey: varchar("field_key", { length: 255 }).notNull(), + fieldType: tinyint("field_type").notNull(), + dictModule: int("dict_module"), + isRequired: tinyint("is_required").default(0).notNull(), + limit: int(), + description: varchar({ length: 255 }), + defaultValue: varchar("default_value", { length: 255 }), + defaultOptions: varchar("default_options", { length: 255 }), + sort: int().default(0).notNull(), + status: int().notNull(), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.fieldId], name: "sys_user_field_definition_field_id"}), + unique("uniq_field_name").on(table.fieldName), + unique("uniq_field_key").on(table.fieldKey), +]); + +export const sysUserFieldValue = mysqlTable("sys_user_field_value", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + userId: bigint("user_id", { mode: "number" }).notNull(), + fieldId: int("field_id").notNull(), + value: varchar({ length: 4096 }), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_user_field_value_id"}), + unique("uniq_user_field").on(table.userId, table.fieldId), +]); + +export const sysUserProfile = mysqlTable("sys_user_profile", { + id: bigint({ mode: "number" }).autoincrement().notNull(), + version: int().default(0).notNull(), + name: varchar({ length: 32 }).notNull(), + profileKey: varchar("profile_key", { length: 255 }).notNull(), + description: varchar({ length: 255 }), + content: varchar({ length: 255 }), + createdBy: bigint("created_by", { mode: "number" }).notNull(), + updatedBy: bigint("updated_by", { mode: "number" }).notNull(), + createdAt: datetime("created_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), + updatedAt: datetime("updated_at", { mode: 'string'}).default(sql`(CURRENT_TIMESTAMP)`).notNull(), +}, +(table) => [ + primaryKey({ columns: [table.id], name: "sys_user_profile_id"}), + unique("uniq_name").on(table.name), + unique("uniq_profile_key").on(table.profileKey), +]); diff --git a/config/index.js b/config/index.js index 56c7ae8..17c1144 100644 --- a/config/index.js +++ b/config/index.js @@ -1,3 +1,4 @@ +import { profile } from 'console'; import { config } from 'dotenv'; import path from 'path'; @@ -8,11 +9,20 @@ console.log('[NODE_ENV]:', process.env.NODE_ENV); // 基础配置 const baseConfig = { NODE_ENV: process.env.NODE_ENV || 'development', + env: process.env.NODE_ENV || 'development', + serviceName: 'YuHeng', + description: 'User System', + version: '1.0.0', server: { port: process.env.PORT || 9000, host: process.env.HOST || 'localhost', backlog: process.env.BACKLOG || 511, }, + profile: { + swagger: { + basePath: '/swagger', + } + }, logger: { level: process.env.LOG_LEVEL || 'trace', filePath: process.env.LOG_FILE || '../logs/app.log', diff --git a/migrations/0000_wandering_marvel_boy.sql b/migrations/0000_wandering_marvel_boy.sql deleted file mode 100644 index 9bafbba..0000000 --- a/migrations/0000_wandering_marvel_boy.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE `users` ( - `id` int NOT NULL, - `name` varchar(255), - `email` varchar(255), - CONSTRAINT `users_id` PRIMARY KEY(`id`), - CONSTRAINT `users_email_unique` UNIQUE(`email`) -); diff --git a/migrations/meta/0000_snapshot.json b/migrations/meta/0000_snapshot.json deleted file mode 100644 index d2f208f..0000000 --- a/migrations/meta/0000_snapshot.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "version": "5", - "dialect": "mysql", - "id": "08e581e2-3826-4de5-b172-057ee6a72da0", - "prevId": "00000000-0000-0000-0000-000000000000", - "tables": { - "users": { - "name": "users", - "columns": { - "id": { - "name": "id", - "type": "int", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "name": { - "name": "name", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "email": { - "name": "email", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": { - "users_id": { - "name": "users_id", - "columns": ["id"] - } - }, - "uniqueConstraints": { - "users_email_unique": { - "name": "users_email_unique", - "columns": ["email"] - } - }, - "checkConstraint": {} - } - }, - "views": {}, - "_meta": { - "schemas": {}, - "tables": {}, - "columns": {} - }, - "internal": { - "tables": {}, - "indexes": {} - } -} diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json deleted file mode 100644 index 34e808e..0000000 --- a/migrations/meta/_journal.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "version": "7", - "dialect": "mysql", - "entries": [ - { - "idx": 0, - "version": "5", - "when": 1742369871003, - "tag": "0000_wandering_marvel_boy", - "breakpoints": true - } - ] -} diff --git a/package-lock.json b/package-lock.json index 7e2ae33..fba167f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,8 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@fastify/swagger": "^9.4.2", + "@fastify/swagger-ui": "^5.2.2", "dotenv": "^16.4.7", "drizzle-kit": "^0.30.5", "drizzle-orm": "^0.40.1", @@ -969,6 +971,22 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@fastify/accept-negotiator": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/@fastify/accept-negotiator/-/accept-negotiator-2.0.1.tgz", + "integrity": "sha512-/c/TW2bO/v9JeEgoD/g1G5GxGeCF1Hafdf79WPmUlgYiBXummY0oX3VVq4yFkKKVBKDNlaDUYoab7g38RpPqCQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, "node_modules/@fastify/ajv-compiler": { "version": "4.0.2", "resolved": "https://registry.npmmirror.com/@fastify/ajv-compiler/-/ajv-compiler-4.0.2.tgz", @@ -1050,6 +1068,99 @@ "ipaddr.js": "^2.1.0" } }, + "node_modules/@fastify/send": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/@fastify/send/-/send-3.3.1.tgz", + "integrity": "sha512-6pofeVwaHN+E/MAofCwDqkWUliE3i++jlD0VH/LOfU8TJlCkMUSgKvA9bawDdVXxjve7XrdYMyDmkiYaoGWEtA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@lukeed/ms": "^2.0.2", + "escape-html": "~1.0.3", + "fast-decode-uri-component": "^1.0.1", + "http-errors": "^2.0.0", + "mime": "^3" + } + }, + "node_modules/@fastify/static": { + "version": "8.1.1", + "resolved": "https://registry.npmmirror.com/@fastify/static/-/static-8.1.1.tgz", + "integrity": "sha512-TW9eyVHJLytZNpBlSIqd0bl1giJkEaRaPZG+5AT3L/OBKq9U8D7g/OYmc2NPQZnzPURGhMt3IAWuyVkvd2nOkQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@fastify/accept-negotiator": "^2.0.0", + "@fastify/send": "^3.2.0", + "content-disposition": "^0.5.4", + "fastify-plugin": "^5.0.0", + "fastq": "^1.17.1", + "glob": "^11.0.0" + } + }, + "node_modules/@fastify/swagger": { + "version": "9.4.2", + "resolved": "https://registry.npmmirror.com/@fastify/swagger/-/swagger-9.4.2.tgz", + "integrity": "sha512-WjSUu6QnmysLx1GeX7+oQAQUG/vBK5L8Qzcsht2SEpZiykpHURefMZpf+u3XbwSuH7TjeWOPgGIJIsEgj8AvxQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "fastify-plugin": "^5.0.0", + "json-schema-resolver": "^3.0.0", + "openapi-types": "^12.1.3", + "rfdc": "^1.3.1", + "yaml": "^2.4.2" + } + }, + "node_modules/@fastify/swagger-ui": { + "version": "5.2.2", + "resolved": "https://registry.npmmirror.com/@fastify/swagger-ui/-/swagger-ui-5.2.2.tgz", + "integrity": "sha512-jf8xe+D8Xjc8TqrZhtlJImOWihd8iYFu8dhM01mGg+F04CKUM0zGB9aADE9nxzRUszyWp3wn+uWk89nbAoBMCw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT", + "dependencies": { + "@fastify/static": "^8.0.0", + "fastify-plugin": "^5.0.0", + "openapi-types": "^12.1.3", + "rfdc": "^1.3.1", + "yaml": "^2.4.1" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmmirror.com/@humanfs/core/-/core-0.19.1.tgz", @@ -1116,6 +1227,32 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmmirror.com/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@lukeed/ms": { + "version": "2.0.2", + "resolved": "https://registry.npmmirror.com/@lukeed/ms/-/ms-2.0.2.tgz", + "integrity": "sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/@petamoriken/float16": { "version": "3.9.2", "resolved": "https://registry.npmmirror.com/@petamoriken/float16/-/float16-3.9.2.tgz", @@ -1212,11 +1349,22 @@ } } }, + "node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, "license": "MIT", "dependencies": { "color-convert": "^2.0.1" @@ -1427,7 +1575,6 @@ "version": "1.0.2", "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, "license": "MIT" }, "node_modules/binary-extensions": { @@ -1602,7 +1749,6 @@ "version": "2.0.1", "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, "license": "MIT", "dependencies": { "color-name": "~1.1.4" @@ -1615,7 +1761,6 @@ "version": "1.1.4", "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true, "license": "MIT" }, "node_modules/colorette": { @@ -1631,6 +1776,18 @@ "dev": true, "license": "MIT" }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmmirror.com/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/cookie": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/cookie/-/cookie-1.0.2.tgz", @@ -1663,7 +1820,6 @@ "version": "7.0.6", "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", - "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -1806,6 +1962,15 @@ "node": ">=0.10" } }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmmirror.com/dequal/-/dequal-2.0.3.tgz", @@ -2004,6 +2169,18 @@ "stream-shift": "^1.0.2" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmmirror.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "license": "MIT" + }, "node_modules/end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmmirror.com/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -2221,6 +2398,12 @@ "esbuild": ">=0.12 <1" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmmirror.com/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -2807,6 +2990,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmmirror.com/fsevents/-/fsevents-2.3.3.tgz", @@ -2985,6 +3184,29 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/glob": { + "version": "11.0.1", + "resolved": "https://registry.npmmirror.com/glob/-/glob-11.0.1.tgz", + "integrity": "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==", + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz", @@ -2998,6 +3220,30 @@ "node": ">= 6" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/globals": { "version": "14.0.0", "resolved": "https://registry.npmmirror.com/globals/-/globals-14.0.0.tgz", @@ -3141,6 +3387,22 @@ "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", "license": "MIT" }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "license": "MIT", + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -3401,6 +3663,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/is-generator-function": { "version": "1.1.0", "resolved": "https://registry.npmmirror.com/is-generator-function/-/is-generator-function-1.1.0.tgz", @@ -3635,9 +3906,23 @@ "version": "2.0.0", "resolved": "https://registry.npmmirror.com/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true, "license": "ISC" }, + "node_modules/jackspeak": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/jackspeak/-/jackspeak-4.1.0.tgz", + "integrity": "sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/joycon": { "version": "3.1.1", "resolved": "https://registry.npmmirror.com/joycon/-/joycon-3.1.1.tgz", @@ -3686,6 +3971,23 @@ "dequal": "^2.0.3" } }, + "node_modules/json-schema-resolver": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/json-schema-resolver/-/json-schema-resolver-3.0.0.tgz", + "integrity": "sha512-HqMnbz0tz2DaEJ3ntsqtx3ezzZyDE7G56A/pPY/NGmrPu76UzsWquOpHFRAf5beTNXoH2LU5cQePVvRli1nchA==", + "license": "MIT", + "dependencies": { + "debug": "^4.1.1", + "fast-uri": "^3.0.5", + "rfdc": "^1.1.4" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/Eomm/json-schema-resolver?sponsor=1" + } + }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -3820,6 +4122,18 @@ "node": ">= 0.4" } }, + "node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmmirror.com/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmmirror.com/minimatch/-/minimatch-3.1.2.tgz", @@ -3842,6 +4156,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmmirror.com/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmmirror.com/ms/-/ms-2.1.3.tgz", @@ -4041,6 +4364,12 @@ "wrappy": "1" } }, + "node_modules/openapi-types": { + "version": "12.1.3", + "resolved": "https://registry.npmmirror.com/openapi-types/-/openapi-types-12.1.3.tgz", + "integrity": "sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==", + "license": "MIT" + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmmirror.com/optionator/-/optionator-0.9.4.tgz", @@ -4109,6 +4438,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "license": "BlueOak-1.0.0" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmmirror.com/parent-module/-/parent-module-1.0.1.tgz", @@ -4136,7 +4471,6 @@ "version": "3.1.1", "resolved": "https://registry.npmmirror.com/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -4149,6 +4483,31 @@ "dev": true, "license": "MIT" }, + "node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.0.2", + "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-11.0.2.tgz", + "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==", + "license": "ISC", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-2.3.1.tgz", @@ -4752,11 +5111,16 @@ "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -4769,7 +5133,6 @@ "version": "3.0.0", "resolved": "https://registry.npmmirror.com/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -4863,6 +5226,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmmirror.com/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/simple-update-notifier": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", @@ -4922,6 +5297,15 @@ "node": ">= 0.6" } }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/stream-shift": { "version": "1.0.3", "resolved": "https://registry.npmmirror.com/stream-shift/-/stream-shift-1.0.3.tgz", @@ -4937,6 +5321,65 @@ "safe-buffer": "~5.2.0" } }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/string.prototype.trim": { "version": "1.2.10", "resolved": "https://registry.npmmirror.com/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz", @@ -4996,6 +5439,43 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmmirror.com/strip-bom/-/strip-bom-3.0.0.tgz", @@ -5075,6 +5555,15 @@ "node": ">=12" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, "node_modules/touch": { "version": "3.1.1", "resolved": "https://registry.npmmirror.com/touch/-/touch-3.1.1.tgz", @@ -5235,7 +5724,6 @@ "version": "2.0.2", "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -5346,12 +5834,112 @@ "node": ">=0.10.0" } }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmmirror.com/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmmirror.com/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "license": "ISC" }, + "node_modules/yaml": { + "version": "2.7.0", + "resolved": "https://registry.npmmirror.com/yaml/-/yaml-2.7.0.tgz", + "integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==", + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmmirror.com/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 4147b63..c6e5cfa 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,8 @@ "author": "", "license": "ISC", "dependencies": { + "@fastify/swagger": "^9.4.2", + "@fastify/swagger-ui": "^5.2.2", "dotenv": "^16.4.7", "drizzle-kit": "^0.30.5", "drizzle-orm": "^0.40.1", diff --git a/rbac_system.sql b/rbac_system.sql deleted file mode 100644 index f811286..0000000 --- a/rbac_system.sql +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 核心用户体系 - * 存储系统用户基础身份信息 - */ -CREATE TABLE `sys_user` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '用户ID(自增主键)', - `username` VARCHAR(50) NOT NULL COMMENT '用户名(唯一标识,必须小写字母开头)', - `email` VARCHAR(100) NOT NULL COMMENT '邮箱(唯一标识,格式校验由程序控制)', - `phone` VARCHAR(20) COMMENT '手机号(国际区号+号码,例如+8613912345678)', - `is_locked` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '账户锁定状态(0-正常 1-锁定)', - `last_login_at` DATETIME COMMENT '最后登录时间(UTC时区)', - `avatar_url` VARCHAR(255) COMMENT '头像URL(CDN地址,格式:https://域名/路径)', - `user_type` VARCHAR(20) NOT NULL DEFAULT 'SYSTEM' COMMENT '用户类型(SYSTEM:系统用户/EXTERNAL:外部用户)', - `parent_id` BIGINT COMMENT '父用户ID(构建用户树形结构,NULL表示根节点)', - `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(自动生成,不可修改)', - `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间(记录最后修改时间)', - PRIMARY KEY (`id`) COMMENT '主键约束', - UNIQUE INDEX `idx_username` (`username`) COMMENT '用户名唯一索引(加速登录验证)', - UNIQUE INDEX `idx_email` (`email`) COMMENT '邮箱唯一索引(保证账号唯一性)', - FOREIGN KEY (`parent_id`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL COMMENT '外键约束(父用户删除时置空,防止数据不一致)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户主表(存储核心身份信息)'; - --- 用户认证体系相关表(密码分离存储) -CREATE TABLE `sys_user_auth` ( - `user_id` BIGINT NOT NULL COMMENT '用户ID(与sys_user.id一对一绑定)', - `password_hash` VARCHAR(128) NOT NULL COMMENT 'BCrypt加密哈希值(固定60字符长度)', - `password_modified` DATETIME NOT NULL COMMENT '密码最后修改时间(UTC时区)', - `password_expire` DATETIME COMMENT '密码过期时间(NULL表示永不过期)', - PRIMARY KEY (`user_id`) COMMENT '主键约束', - FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE COMMENT '级联删除(用户删除时自动删除认证信息)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户认证表(存储敏感凭证信息)'; - --- 密码历史记录表(防止重复使用旧密码) -CREATE TABLE `sys_password_history` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '记录ID(自增主键)', - `user_id` BIGINT NOT NULL COMMENT '用户ID(与sys_user.id关联)', - `old_password` VARCHAR(128) NOT NULL COMMENT '历史密码哈希值', - `modified_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(UTC时区)', - PRIMARY KEY (`id`) COMMENT '主键约束', - INDEX `idx_user_pwd` (`user_id`, `modified_at`) COMMENT '复合索引(加速历史密码查询)', - FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE COMMENT '级联删除(用户删除时自动清理历史记录)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='密码历史表(保存最近N次历史密码)'; - --- 组织架构体系相关表(支持树形结构) -CREATE TABLE `sys_organization` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '组织ID(自增主键)', - `org_name` VARCHAR(100) NOT NULL COMMENT '组织名称(显示用中文名)', - `org_code` VARCHAR(50) NOT NULL COMMENT '组织编码(唯一业务标识,如DEP001)', - `parent_id` BIGINT COMMENT '父组织ID(构建树形结构,NULL表示根节点)', - `manager_id` BIGINT COMMENT '负责人ID(关联sys_user.id)', - `tags` JSON COMMENT '组织标签(JSON数组,如["子公司","研发中心"])', - `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(UTC时区)', - `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间(UTC时区)', - PRIMARY KEY (`id`) COMMENT '主键约束', - UNIQUE INDEX `idx_org_code` (`org_code`) COMMENT '组织编码唯一索引', - FOREIGN KEY (`parent_id`) REFERENCES `sys_organization` (`id`) COMMENT '外键约束(维护树形结构完整性)', - FOREIGN KEY (`manager_id`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL COMMENT '外键约束(负责人删除时置空)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='组织架构表(支持多层级结构)'; - - -/* - * RBAC核心表(基于角色的访问控制) - * 包含角色、权限及其关联关系 - */ -CREATE TABLE `sys_role` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '角色ID(自增主键)', - `role_name` VARCHAR(50) NOT NULL COMMENT '角色名称(显示用中文名)', - `role_key` VARCHAR(50) NOT NULL COMMENT '角色标识符(唯一英文键,如admin)', - `description` VARCHAR(255) COMMENT '角色描述(功能说明)', - `parent_id` BIGINT COMMENT '父角色ID(构建角色继承树)', - PRIMARY KEY (`id`), - UNIQUE INDEX `idx_role_key` (`role_key`) COMMENT '角色标识符唯一索引', - FOREIGN KEY (`parent_id`) REFERENCES `sys_role` (`id`) COMMENT '外键约束(维护角色继承关系)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表(定义系统角色)'; - -CREATE TABLE `sys_permission` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '权限ID(自增主键)', - `perm_name` VARCHAR(50) NOT NULL COMMENT '权限名称(显示用中文名)', - `perm_key` VARCHAR(100) NOT NULL COMMENT '权限标识符(唯一业务键,如user:delete)', - `description` VARCHAR(255) COMMENT '权限描述(功能说明)', - `parent_id` BIGINT COMMENT '父权限ID(构建权限树形结构)', - PRIMARY KEY (`id`), - UNIQUE INDEX `idx_perm_key` (`perm_key`) COMMENT '权限标识符唯一索引', - FOREIGN KEY (`parent_id`) REFERENCES `sys_permission` (`id`) COMMENT '外键约束(维护权限继承关系)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='权限表(定义细粒度权限)'; - --- 用户-角色关联表(多对多关系) -CREATE TABLE `sys_user_role` ( - `user_id` BIGINT NOT NULL COMMENT '用户ID(关联sys_user.id)', - `role_id` BIGINT NOT NULL COMMENT '角色ID(关联sys_role.id)', - PRIMARY KEY (`user_id`, `role_id`) COMMENT '复合主键', - FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE COMMENT '级联删除(用户删除时自动解除关联)', - FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`) ON DELETE CASCADE COMMENT '级联删除(角色删除时自动解除关联)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户角色关联表(建立用户与角色的多对多关系)'; - --- 角色-权限关联表(多对多关系) -CREATE TABLE `sys_role_permission` ( - `role_id` BIGINT NOT NULL COMMENT '角色ID(关联sys_role.id)', - `perm_id` BIGINT NOT NULL COMMENT '权限ID(关联sys_permission.id)', - PRIMARY KEY (`role_id`, `perm_id`) COMMENT '复合主键', - FOREIGN KEY (`role_id`) REFERENCES `sys_role` (`id`) ON DELETE CASCADE COMMENT '级联删除(角色删除时自动解除关联)', - FOREIGN KEY (`perm_id`) REFERENCES `sys_permission` (`id`) ON DELETE CASCADE COMMENT '级联删除(权限删除时自动解除关联)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色权限关联表(建立角色与权限的多对多关系)'; - -/* - * 扩展字段体系(支持动态字段管理) - * 包含字段定义和用户扩展数据存储 - */ -CREATE TABLE `sys_field_definition` ( - `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '字段ID(自增主键)', - `field_key` VARCHAR(50) NOT NULL COMMENT '字段标识符(英文唯一键,如birthday)', - `field_name` VARCHAR(50) NOT NULL COMMENT '字段显示名称(如"出生日期")', - `field_type` ENUM('STRING','NUMBER','DATE','BOOLEAN','TEXT') NOT NULL DEFAULT 'STRING' COMMENT '字段类型(控制数据格式)', - `is_required` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否必填(0-否 1-是)', - `is_unique` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否唯一(0-否 1-是)', - `user_types` JSON NOT NULL COMMENT '适用的用户类型(JSON数组,如["SYSTEM","EXTERNAL"])', - `status` TINYINT(1) NOT NULL DEFAULT 1 COMMENT '状态(0-停用 1-启用)', - `created_by` BIGINT NOT NULL COMMENT '创建人ID(关联sys_user.id)', - `updated_by` BIGINT NOT NULL COMMENT '最后修改人ID(关联sys_user.id)', - `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(UTC时区)', - `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间(UTC时区)', - PRIMARY KEY (`id`), - UNIQUE INDEX `idx_field_key` (`field_key`) COMMENT '字段标识符唯一索引', - FOREIGN KEY (`created_by`) REFERENCES `sys_user` (`id`) COMMENT '外键约束(创建人必须存在)', - FOREIGN KEY (`updated_by`) REFERENCES `sys_user` (`id`) COMMENT '外键约束(修改人必须存在)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='字段定义表(管理员维护动态字段)'; - -CREATE TABLE `sys_user_profile` ( - `user_id` BIGINT NOT NULL COMMENT '用户ID(关联sys_user.id)', - `field_id` BIGINT NOT NULL COMMENT '字段ID(关联sys_field_definition.id)', - `field_value` TEXT NOT NULL COMMENT '字段值(根据字段类型校验格式)', - `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(UTC时区)', - `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间(UTC时区)', - PRIMARY KEY (`user_id`, `field_id`) COMMENT '复合主键', - FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE COMMENT '级联删除(用户删除时自动清理扩展数据)', - FOREIGN KEY (`field_id`) REFERENCES `sys_field_definition` (`id`) COMMENT '外键约束(确保字段定义有效)' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户扩展表(存储动态字段数据)'; \ No newline at end of file diff --git a/src/plugins/database/index.js b/src/plugins/database/index.js index 367b67d..8deeae6 100644 --- a/src/plugins/database/index.js +++ b/src/plugins/database/index.js @@ -24,5 +24,8 @@ async function database(fastify, options) { const tableList = result.map(row => Object.values(row)[0]); db.tableList = tableList; fastify.decorate('db', db); + + // 读取数据库基本信息 + fastify.log.warn('Register Database Complete! => DATABASE TABLES: ' + fastify.db.tableList.length); } export default fastifyPlugin(database); diff --git a/src/plugins/index.js b/src/plugins/index.js index 163d9a5..b1cb446 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -1,5 +1,6 @@ import fp from 'fastify-plugin'; import database from '#plugins/database/index'; +import swagger from '#plugins/swagger/index'; async function plugin(fastify, opts) { fastify.log.warn('Register Global Plugin!'); @@ -7,8 +8,8 @@ async function plugin(fastify, opts) { fastify.decorate('config', opts.config); // 注册数据库 await fastify.register(database); - fastify.log.warn(fastify.db.tableList); - // 读取数据库基本信息 + // 注册swagger + fastify.config.env === 'development' && await fastify.register(swagger); fastify.log.warn('Register Global Plugin complete!'); } export default fp(plugin); diff --git a/src/plugins/swagger/index.js b/src/plugins/swagger/index.js new file mode 100644 index 0000000..ebe3fb2 --- /dev/null +++ b/src/plugins/swagger/index.js @@ -0,0 +1,25 @@ +import fastifyPlugin from "fastify-plugin"; +import fastifySwagger from "@fastify/swagger"; +import fastifySwaggerUI from "@fastify/swagger-ui"; +async function swagger(fastify, options) { + // 注册swagger插件(新版配置方式) + fastify.log.warn('Register Swagger Plugin!'); + await fastify.register(fastifySwagger, { + openapi: { + info: { + title: `${fastify.config.serviceName} API`, + version: fastify.config.version, + description: fastify.config.description + }, + }, + // staticCSP: true, // 启用安全策略 + exposeRoute: true // 自动暴露路由 + }); + // 注册swagger-ui界面 (新增部分) + await fastify.register(fastifySwaggerUI, { + routePrefix: '/docs', + }); + fastify.log.warn('Register Swagger complete!'); +} + +export default fastifyPlugin(swagger); \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index 097c207..6097694 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -1,7 +1,51 @@ +import { testSchema } from "#src/schema/test.schema"; +import { testService } from "#src/services/test.service"; + export default async function routes(fastify, options) { // 定义一个GET请求的路由,路径为根路径 fastify.get('/', async (request, reply) => { fastify.log.info(fastify.config); return fastify.config; }); + fastify.get('/test', testSchema , testService); + fastify.route({ + method: 'POST', + url: '/login', + schema: { + tags: ['认证体系'], // 接口分组 + summary: '用户登录', + description: '使用用户名密码进行身份认证', + security: [{ + }], + body: { + type: 'object', + required: ['username', 'password'], + properties: { + username: { type: 'string', default: 'user1' }, + password: { type: 'string', default: '123456' } + } + }, + response: { + 200: { + description: '登录成功', + type: 'object', + properties: { + token: { type: 'string' }, + expire: { type: 'number' } + } + }, + 401: { + description: '认证失败', + type: 'object', + properties: { + code: { type: 'number', enum: [401] }, + error: { type: 'string' } + } + } + } + }, + handler: async (req, reply) => { + // ...业务逻辑... + } + }); } diff --git a/src/schema/test.schema.js b/src/schema/test.schema.js new file mode 100644 index 0000000..7b567fd --- /dev/null +++ b/src/schema/test.schema.js @@ -0,0 +1,31 @@ +export const testSchema = { + tags: ['测试'], + summary: '测试接口', + description: '使用用户名密码进行身份认证', + params: { + type: 'object', + required: ['username', 'password'], + properties: { + username: { type:'string', default: 'user1' }, + password: { type:'string', default: '123456' } + } + }, + response: { + 200: { + description: '登录成功', + type: 'object', + properties: { + token: { type:'string' }, + expire: { type: 'number' } + } + }, + 401: { + description: '认证失败', + type: 'object', + properties: { + code: { type: 'number', enum: [401] }, + error: { type:'string' } + } + } + } +} \ No newline at end of file diff --git a/src/services/test.service.js b/src/services/test.service.js new file mode 100644 index 0000000..bae8877 --- /dev/null +++ b/src/services/test.service.js @@ -0,0 +1,6 @@ +export async function testService(request, reply) { + this.log.warn('testService'); + return { + test: 'test' + } +} \ No newline at end of file diff --git a/src/utils/logger.js b/src/utils/logger.js index 1ec265e..913ff9d 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -8,6 +8,7 @@ export default { // 修正为独立的多传输配置 targets: [ config.logger.console && { + level: config.logger.level, target: 'pino-pretty', options: { colorize: true, diff --git a/yuheng.sql b/yuheng.sql index 825ed11..252f043 100644 --- a/yuheng.sql +++ b/yuheng.sql @@ -1,92 +1,154 @@ -CREATE TABLE `sys_dict` ( - `id` int NOT NULL, - `pid` int NULL, - `module` tinyint NULL, - `key` varchar(255) NULL, - `value` varchar(255) NULL, - PRIMARY KEY (`id`) -); +CREATE TABLE `sys_dict` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'ID', + `version` INT NOT NULL DEFAULT 0, + `pid` BIGINT NOT NULL COMMENT '上级ID', + `module` tinyint NULL COMMENT '模块', + `dict_key` varchar(255) NULL COMMENT '字典标识', + `value` varchar(255) NULL COMMENT '字典值', + `description` varchar(255) NULL COMMENT '描述', + `sort` int NOT NULL DEFAULT 0 COMMENT '排序', + `status` int NOT NULL COMMENT '状态 0启用 1禁用', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_dict_key` (`dict_key`, `pid`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '字典表'; -CREATE TABLE `sys_organization` ( - `org_id` bigint NOT NULL, - `pid` bigint NULL, - `org_name` varchar(255) NULL, - `org_code` varchar(128) NULL, - `org_type` int NULL, - `desc` varchar(255) NULL, - PRIMARY KEY (`org_id`) -); +CREATE TABLE `sys_organization` ( + `org_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '组织ID', + `pid` BIGINT DEFAULT 0 NOT NULL COMMENT '上级组织ID', + `org_name` varchar(255) NULL COMMENT '组织名称', + `org_code` varchar(128) NULL COMMENT '组织编码', + `org_type` int NOT NULL COMMENT '组织类型', + `description` varchar(255) NULL COMMENT '描述', + `sort` int NOT NULL DEFAULT 0 COMMENT '排序', + `status` int NOT NULL COMMENT '状态', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`org_id`), + UNIQUE `uniq_org_code` (`org_code`, `pid`), + UNIQUE `uniq_org_name` (`org_name`, `pid`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '组织表'; -CREATE TABLE `sys_organization_manager` ( - `id` bigint NOT NULL COMMENT '1', - `org_id` bigint NOT NULL COMMENT '1', - `user_id` bigint NOT NULL COMMENT '1', - `rank` int NOT NULL COMMENT '1', - `status` int ZEROFILL NOT NULL COMMENT '1', - `desc` varchar(255) NULL, - PRIMARY KEY (`id`) -); +CREATE TABLE `sys_organization_manager` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'ID', + `version` INT NOT NULL DEFAULT 0, + `org_id` bigint NOT NULL COMMENT '组织ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `rank` int NOT NULL COMMENT '当前用户对组织管理的级别,1为最高级别', + `description` varchar(255) NULL, + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_org_user` (`org_id`, `user_id`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '组织负责人表'; -CREATE TABLE `sys_permission` ( - `perm_id` int NOT NULL, - `pid` int NULL, - `perm_name` varchar(255) NULL, - `perm_key` varchar(255) NULL, - `avatar_url` varchar(255) NULL, - `desc` varchar(255) NULL, - `perm_type` varchar(255) NULL, - PRIMARY KEY (`perm_id`) -); +CREATE TABLE `sys_permission` ( + `perm_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '权限ID', + `pid` BIGINT NOT NULL DEFAULT 0 COMMENT '上级权限ID', + `perm_name` varchar(255) NOT NULL COMMENT '权限名称', + `perm_key` varchar(255) NOT NULL COMMENT '权限标识', + `url` varchar(255) NULL COMMENT '权限路径', + `avatar_url` varchar(255) NULL COMMENT '权限图标', + `description` varchar(255) NULL COMMENT '描述', + `perm_type` int NOT NULL COMMENT '权限类型', + `is_visible` int NOT NULL DEFAULT 0 COMMENT '是否可见', + `version` INT NOT NULL DEFAULT 0, + `sort` int NOT NULL DEFAULT 0 COMMENT '排序', + `status` int NOT NULL COMMENT '状态', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`perm_id`), + UNIQUE `uniq_pid_name` (`perm_name`, `pid`), + UNIQUE `uniq_perm_key` (`perm_key`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '权限表'; -CREATE TABLE `sys_re_role_permission` ( - `id` int NOT NULL, - `role_id` int NULL, - `perm_id` int NULL, - PRIMARY KEY (`id`) -); +CREATE TABLE `sys_re_role_permission` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '关系ID', + `role_id` BIGINT NOT NULL COMMENT '角色ID', + `perm_id` BIGINT NOT NULL COMMENT '权限ID', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_perm_role` (`role_id`, `perm_id`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户组织关系表'; -CREATE TABLE `sys_re_user_organization` ( - `id` int NOT NULL, - `user_id` int NULL, - `org_id` int NULL, - PRIMARY KEY (`id`) -); +CREATE TABLE `sys_re_user_organization` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '关系ID', + `user_id` BIGINT NOT NULL COMMENT '用户ID', + `org_id` BIGINT NOT NULL COMMENT '组织ID', + `version` INT NOT NULL DEFAULT 0, + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_user_org` (`user_id`, `org_id`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户组织关系表'; -CREATE TABLE `sys_re_user_role` ( - `id` int NOT NULL, - `user_id` int NULL, - `role_id` int NULL, - PRIMARY KEY (`id`) -); +CREATE TABLE `sys_re_user_role` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '关系ID', + `user_id` BIGINT NOT NULL COMMENT '用户ID', + `role_id` BIGINT NOT NULL COMMENT '角色ID', + `version` INT NOT NULL DEFAULT 0, + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_user_role` (`user_id`, `role_id`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户角色关联表';; -CREATE TABLE `sys_role` ( - `role_id` int NOT NULL, - `pid` int NULL, - `role_name` varchar(255) NULL, - `role_key` varchar(255) NULL, - `desc` varchar(255) NULL, - PRIMARY KEY (`role_id`) -); +CREATE TABLE `sys_role` ( + `role_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '角色ID', + `pid` BIGINT NOT NULL COMMENT '上级角色ID', + `role_name` varchar(255) NOT NULL COMMENT '角色名称', + `role_key` varchar(255) NOT NULL COMMENT '角色表示', + `description` varchar(255) NULL COMMENT '角色描述', + `status` int NOT NULL COMMENT '状态', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`role_id`), + UNIQUE `uniq_role_pid` (`role_name`, `pid`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户角色表'; CREATE TABLE `sys_user` ( `user_id` bigint NOT NULL COMMENT '用户ID', - `pid` bigint ZEROFILL NOT NULL COMMENT '上级ID', + `pid` bigint NOT NULL COMMENT '上级ID', `username` varchar(255) NOT NULL COMMENT '用户名,全小写', `email` varchar(255) NOT NULL COMMENT '邮箱', `phone` varchar(255) NULL COMMENT '手机号', `avatar_url` varchar(255) NULL COMMENT '图标', `user_type` tinyint NULL DEFAULT NULL COMMENT '用户类型从字典取', `status` tinyint DEFAULT 0 NOT NULL COMMENT '状态', - PRIMARY KEY (`user_id`) -) COMMENT '用户基础信息表'; + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`user_id`), + UNIQUE `uniq_username` (`username`), + UNIQUE `uniq_email` (`email`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户基础信息表'; CREATE TABLE `sys_user_auth` ( `user_id` bigint NOT NULL COMMENT '用户ID', `password_hash` varchar(255) NOT NULL COMMENT '用户密码', - `password_modified` varchar(255) NOT NULL COMMENT '上一次修改时间', - `password_expire` varchar(255) NULL DEFAULT NULL COMMENT '过期时间', + `password_modified` DATETIME NOT NULL COMMENT '上一次修改时间', + `password_expire` DATETIME NULL DEFAULT NULL COMMENT '过期时间', PRIMARY KEY (`user_id`) -) COMMENT '用户密码表'; +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户密码表'; CREATE TABLE `sys_user_auth_history` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '历史记录自增主键', @@ -94,34 +156,57 @@ CREATE TABLE `sys_user_auth_history` ( `password_hash` varchar(255) NOT NULL COMMENT '历史密码值,注意需要限制密码更改次数', `modified_at` varchar(255) NOT NULL COMMENT '上次修改的时间', PRIMARY KEY (`id`) -) COMMENT '历史密码表'; +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '历史密码表'; -CREATE TABLE `sys_user_field_definition` ( - `field_id` int NOT NULL AUTO_INCREMENT COMMENT '用户拓展字段ID', +CREATE TABLE `sys_user_field_definition` ( + `field_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '用户拓展字段ID', + `version` INT NOT NULL DEFAULT 0, `field_name` varchar(255) NOT NULL COMMENT '拓展字段名称', `field_key` varchar(255) NOT NULL COMMENT '拓展字段标识', `field_type` tinyint NOT NULL COMMENT '拓展字段类型0文字1数字2日期3单选4多选5附件6富文本', `dict_module` int NULL COMMENT '字典集模块值', `is_required` tinyint NOT NULL DEFAULT 0 COMMENT '是否必填0否1是', `limit` int NULL COMMENT '值长度,最大2048', - PRIMARY KEY (`field_id`) -) COMMENT '用户拓展字段定义表'; + `description` varchar(255) NULL COMMENT '描述', + `default_value` varchar(255) NULL COMMENT '默认值', + `default_options` varchar(255) NULL COMMENT '选项值', + `sort` int NOT NULL DEFAULT 0 COMMENT '排序', + `status` int NOT NULL COMMENT '状态', + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`field_id`), + UNIQUE `uniq_field_name` (`field_name`), + UNIQUE `uniq_field_key` (`field_key`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户拓展字段定义表'; CREATE TABLE `sys_user_field_value` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户拓展字段记录id', `user_id` bigint NOT NULL COMMENT '用户ID', `field_id` int NOT NULL COMMENT '字段ID', - `dictId` int NULL COMMENT '使用字典后的字典ID', `value` varchar(4096) NULL COMMENT '用户拓展字段值', - PRIMARY KEY (`id`) -) COMMENT '用户拓展字段记录表'; + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_user_field` (`user_id`, `field_id`) +)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '用户拓展字段记录表'; -CREATE TABLE `sys_user_profile` ( - `id` int NOT NULL AUTO_INCREMENT COMMENT '系统配置自增主键', +CREATE TABLE `sys_user_profile` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '系统配置自增主键', + `version` INT NOT NULL DEFAULT 0, `name` varchar(32) NOT NULL COMMENT '系统配置名称', - `key` varchar(255) NOT NULL COMMENT '系统配置记录Key', - `desc` varchar(255) NULL COMMENT '系统配置记录描述', + `profile_key` varchar(255) NOT NULL COMMENT '系统配置记录Key', + `description` varchar(255) NULL COMMENT '系统配置记录描述', `content` varchar(255) NULL COMMENT '系统配置记录值', - PRIMARY KEY (`id`) -) COMMENT '系统配置'; + `created_by` bigint NOT NULL COMMENT '创建人', + `updated_by` bigint NOT NULL COMMENT '更新人', + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + UNIQUE `uniq_name` (`name`), + UNIQUE `uniq_profile_key` (`profile_key`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '系统配置';