From 2b76b64e859533140982728021dfd0f1777488d5 Mon Sep 17 00:00:00 2001 From: Wu Clan Date: Tue, 16 Dec 2025 19:55:01 +0800 Subject: [PATCH] Add code generation and notice SQL scripts (#966) --- .../plugin/code_generator/sql/mysql/init.sql | 24 +++++++++++++++++ .../sql/mysql/init_snowflake.sql | 24 +++++++++++++++++ .../code_generator/sql/postgresql/init.sql | 27 +++++++++++++++++++ .../sql/postgresql/init_snowflake.sql | 24 +++++++++++++++++ backend/plugin/notice/sql/mysql/init.sql | 18 +++++++++++++ .../notice/sql/mysql/init_snowflake.sql | 18 +++++++++++++ backend/plugin/notice/sql/postgresql/init.sql | 20 ++++++++++++++ .../notice/sql/postgresql/init_snowflake.sql | 18 +++++++++++++ 8 files changed, 173 insertions(+) create mode 100644 backend/plugin/code_generator/sql/mysql/init.sql create mode 100644 backend/plugin/code_generator/sql/mysql/init_snowflake.sql create mode 100644 backend/plugin/code_generator/sql/postgresql/init.sql create mode 100644 backend/plugin/code_generator/sql/postgresql/init_snowflake.sql create mode 100644 backend/plugin/notice/sql/mysql/init.sql create mode 100644 backend/plugin/notice/sql/mysql/init_snowflake.sql create mode 100644 backend/plugin/notice/sql/postgresql/init.sql create mode 100644 backend/plugin/notice/sql/postgresql/init_snowflake.sql diff --git a/backend/plugin/code_generator/sql/mysql/init.sql b/backend/plugin/code_generator/sql/mysql/init.sql new file mode 100644 index 00000000..5f47473f --- /dev/null +++ b/backend/plugin/code_generator/sql/mysql/init.sql @@ -0,0 +1,24 @@ +insert into gen_business (id, app_name, table_name, doc_comment, table_comment, class_name, schema_name, filename, default_datetime_column, api_version, gen_path, remark, created_time, updated_time) +values (1, 'test', 'sys_opera_log', '操作日志表', '操作日志表', 'SysOperaLog', 'SysOperaLog', 'sys_opera_log', true, 'v1', null, null, '2025-12-15 15:30:33', null); + +insert into gen_column (id, name, comment, type, pd_type, `default`, sort, `length`, is_pk, is_nullable, gen_business_id) +values +(1, 'trace_id', '请求跟踪 ID', 'String', 'str', null, 2, 32, false, false, 1), +(2, 'username', '用户名', 'String', 'str', null, 3, 64, false, true, 1), +(3, 'method', '请求类型', 'String', 'str', null, 4, 32, false, false, 1), +(4, 'title', '操作模块', 'String', 'str', null, 5, 256, false, false, 1), +(5, 'path', '请求路径', 'String', 'str', null, 6, 512, false, false, 1), +(6, 'ip', 'IP地址', 'String', 'str', null, 7, 64, false, false, 1), +(7, 'country', '国家', 'String', 'str', null, 8, 64, false, true, 1), +(8, 'region', '地区', 'String', 'str', null, 9, 64, false, true, 1), +(9, 'city', '城市', 'String', 'str', null, 10, 64, false, true, 1), +(10, 'user_agent', '请求头', 'String', 'str', null, 11, 512, false, false, 1), +(11, 'os', '操作系统', 'String', 'str', null, 12, 64, false, true, 1), +(12, 'browser', '浏览器', 'String', 'str', null, 13, 64, false, true, 1), +(13, 'device', '设备', 'String', 'str', null, 14, 64, false, true, 1), +(14, 'args', '请求参数', 'JSON', 'dict', null, 15, 0, false, true, 1), +(15, 'status', '操作状态(0异常 1正常)', 'INTEGER', 'int', null, 16, 0, false, false, 1), +(16, 'code', '操作状态码', 'String', 'str', null, 17, 32, false, false, 1), +(17, 'msg', '提示消息', 'TEXT', 'str', null, 18, 0, false, true, 1), +(18, 'cost_time', '请求耗时(ms)', 'String', 'str', null, 19, 0, false, false, 1), +(19, 'opera_time', '操作时间', 'String', 'str', null, 20, 0, false, false, 1); diff --git a/backend/plugin/code_generator/sql/mysql/init_snowflake.sql b/backend/plugin/code_generator/sql/mysql/init_snowflake.sql new file mode 100644 index 00000000..3cba2a9f --- /dev/null +++ b/backend/plugin/code_generator/sql/mysql/init_snowflake.sql @@ -0,0 +1,24 @@ +insert into gen_business (id, app_name, table_name, doc_comment, table_comment, class_name, schema_name, filename, default_datetime_column, api_version, gen_path, remark, created_time, updated_time) +values (2112248797819043840, 'test', 'sys_opera_log', '操作日志表', '操作日志表', 'SysOperaLog', 'SysOperaLog', 'sys_opera_log', true, 'v1', null, null, '2025-12-15 15:30:33', null); + +insert into gen_column (id, name, comment, type, pd_type, `default`, sort, `length`, is_pk, is_nullable, gen_business_id) +values +(2112248797881958400, 'trace_id', '请求跟踪 ID', 'String', 'str', null, 2, 32, false, false, 2112248797819043840), +(2112248797944872960, 'username', '用户名', 'String', 'str', null, 3, 64, false, true, 2112248797819043840), +(2112248798007787520, 'method', '请求类型', 'String', 'str', null, 4, 32, false, false, 2112248797819043840), +(2112248798070702080, 'title', '操作模块', 'String', 'str', null, 5, 256, false, false, 2112248797819043840), +(2112248798133616640, 'path', '请求路径', 'String', 'str', null, 6, 512, false, false, 2112248797819043840), +(2112248798196531200, 'ip', 'IP地址', 'String', 'str', null, 7, 64, false, false, 2112248797819043840), +(2112248798259445760, 'country', '国家', 'String', 'str', null, 8, 64, false, true, 2112248797819043840), +(2112248798322360320, 'region', '地区', 'String', 'str', null, 9, 64, false, true, 2112248797819043840), +(2112248798385274880, 'city', '城市', 'String', 'str', null, 10, 64, false, true, 2112248797819043840), +(2112248798448189440, 'user_agent', '请求头', 'String', 'str', null, 11, 512, false, false, 2112248797819043840), +(2112248798511104000, 'os', '操作系统', 'String', 'str', null, 12, 64, false, true, 2112248797819043840), +(2112248798574018560, 'browser', '浏览器', 'String', 'str', null, 13, 64, false, true, 2112248797819043840), +(2112248798636933120, 'device', '设备', 'String', 'str', null, 14, 64, false, true, 2112248797819043840), +(2112248798699847680, 'args', '请求参数', 'JSON', 'dict', null, 15, 0, false, true, 2112248797819043840), +(2112248798762762240, 'status', '操作状态(0异常 1正常)', 'INTEGER', 'int', null, 16, 0, false, false, 2112248797819043840), +(2112248798825676800, 'code', '操作状态码', 'String', 'str', null, 17, 32, false, false, 2112248797819043840), +(2112248798888591360, 'msg', '提示消息', 'TEXT', 'str', null, 18, 0, false, true, 2112248797819043840), +(2112248798951505920, 'cost_time', '请求耗时(ms)', 'String', 'str', null, 19, 0, false, false, 2112248797819043840), +(2112248799014420480, 'opera_time', '操作时间', 'String', 'str', null, 20, 0, false, false, 2112248797819043840); diff --git a/backend/plugin/code_generator/sql/postgresql/init.sql b/backend/plugin/code_generator/sql/postgresql/init.sql new file mode 100644 index 00000000..80269d28 --- /dev/null +++ b/backend/plugin/code_generator/sql/postgresql/init.sql @@ -0,0 +1,27 @@ +insert into gen_business (id, app_name, table_name, doc_comment, table_comment, class_name, schema_name, filename, default_datetime_column, api_version, gen_path, remark, created_time, updated_time) +values (1, 'test', 'sys_opera_log', '操作日志表', '操作日志表', 'SysOperaLog', 'SysOperaLog', 'sys_opera_log', true, 'v1', null, null, '2025-12-15 15:30:33', null); + +insert into gen_column (id, name, comment, type, pd_type, "default", sort, "length", is_pk, is_nullable, gen_business_id) +values +(1, 'trace_id', '请求跟踪 ID', 'String', 'str', null, 2, 32, false, false, 1), +(2, 'username', '用户名', 'String', 'str', null, 3, 64, false, true, 1), +(3, 'method', '请求类型', 'String', 'str', null, 4, 32, false, false, 1), +(4, 'title', '操作模块', 'String', 'str', null, 5, 256, false, false, 1), +(5, 'path', '请求路径', 'String', 'str', null, 6, 512, false, false, 1), +(6, 'ip', 'IP地址', 'String', 'str', null, 7, 64, false, false, 1), +(7, 'country', '国家', 'String', 'str', null, 8, 64, false, true, 1), +(8, 'region', '地区', 'String', 'str', null, 9, 64, false, true, 1), +(9, 'city', '城市', 'String', 'str', null, 10, 64, false, true, 1), +(10, 'user_agent', '请求头', 'String', 'str', null, 11, 512, false, false, 1), +(11, 'os', '操作系统', 'String', 'str', null, 12, 64, false, true, 1), +(12, 'browser', '浏览器', 'String', 'str', null, 13, 64, false, true, 1), +(13, 'device', '设备', 'String', 'str', null, 14, 64, false, true, 1), +(14, 'args', '请求参数', 'JSON', 'dict', null, 15, 0, false, true, 1), +(15, 'status', '操作状态(0异常 1正常)', 'INTEGER', 'int', null, 16, 0, false, false, 1), +(16, 'code', '操作状态码', 'String', 'str', null, 17, 32, false, false, 1), +(17, 'msg', '提示消息', 'TEXT', 'str', null, 18, 0, false, true, 1), +(18, 'cost_time', '请求耗时(ms)', 'String', 'str', null, 19, 0, false, false, 1), +(19, 'opera_time', '操作时间', 'String', 'str', null, 20, 0, false, false, 1); + +select setval(pg_get_serial_sequence('gen_business', 'id'),coalesce(max(id), 0) + 1, true) from gen_business; +select setval(pg_get_serial_sequence('gen_column', 'id'),coalesce(max(id), 0) + 1, true) from gen_column; diff --git a/backend/plugin/code_generator/sql/postgresql/init_snowflake.sql b/backend/plugin/code_generator/sql/postgresql/init_snowflake.sql new file mode 100644 index 00000000..4d4cd1e6 --- /dev/null +++ b/backend/plugin/code_generator/sql/postgresql/init_snowflake.sql @@ -0,0 +1,24 @@ +insert into gen_business (id, app_name, table_name, doc_comment, table_comment, class_name, schema_name, filename, default_datetime_column, api_version, gen_path, remark, created_time, updated_time) +values (2112248797819043840, 'test', 'sys_opera_log', '操作日志表', '操作日志表', 'SysOperaLog', 'SysOperaLog', 'sys_opera_log', true, 'v1', null, null, '2025-12-15 15:30:33', null); + +insert into gen_column (id, name, comment, type, pd_type, "default", sort, "length", is_pk, is_nullable, gen_business_id) +values +(2112248797881958400, 'trace_id', '请求跟踪 ID', 'String', 'str', null, 2, 32, false, false, 2112248797819043840), +(2112248797944872960, 'username', '用户名', 'String', 'str', null, 3, 64, false, true, 2112248797819043840), +(2112248798007787520, 'method', '请求类型', 'String', 'str', null, 4, 32, false, false, 2112248797819043840), +(2112248798070702080, 'title', '操作模块', 'String', 'str', null, 5, 256, false, false, 2112248797819043840), +(2112248798133616640, 'path', '请求路径', 'String', 'str', null, 6, 512, false, false, 2112248797819043840), +(2112248798196531200, 'ip', 'IP地址', 'String', 'str', null, 7, 64, false, false, 2112248797819043840), +(2112248798259445760, 'country', '国家', 'String', 'str', null, 8, 64, false, true, 2112248797819043840), +(2112248798322360320, 'region', '地区', 'String', 'str', null, 9, 64, false, true, 2112248797819043840), +(2112248798385274880, 'city', '城市', 'String', 'str', null, 10, 64, false, true, 2112248797819043840), +(2112248798448189440, 'user_agent', '请求头', 'String', 'str', null, 11, 512, false, false, 2112248797819043840), +(2112248798511104000, 'os', '操作系统', 'String', 'str', null, 12, 64, false, true, 2112248797819043840), +(2112248798574018560, 'browser', '浏览器', 'String', 'str', null, 13, 64, false, true, 2112248797819043840), +(2112248798636933120, 'device', '设备', 'String', 'str', null, 14, 64, false, true, 2112248797819043840), +(2112248798699847680, 'args', '请求参数', 'JSON', 'dict', null, 15, 0, false, true, 2112248797819043840), +(2112248798762762240, 'status', '操作状态(0异常 1正常)', 'INTEGER', 'int', null, 16, 0, false, false, 2112248797819043840), +(2112248798825676800, 'code', '操作状态码', 'String', 'str', null, 17, 32, false, false, 2112248797819043840), +(2112248798888591360, 'msg', '提示消息', 'TEXT', 'str', null, 18, 0, false, true, 2112248797819043840), +(2112248798951505920, 'cost_time', '请求耗时(ms)', 'String', 'str', null, 19, 0, false, false, 2112248797819043840), +(2112248799014420480, 'opera_time', '操作时间', 'String', 'str', null, 20, 0, false, false, 2112248797819043840); diff --git a/backend/plugin/notice/sql/mysql/init.sql b/backend/plugin/notice/sql/mysql/init.sql new file mode 100644 index 00000000..4ed3246b --- /dev/null +++ b/backend/plugin/notice/sql/mysql/init.sql @@ -0,0 +1,18 @@ +insert into sys_notice (id, title, type, status, content, created_time, updated_time) +values (1, 'hahahahahaahahaha', 0, 1, '你好😄 + +``` +print(''fba yyds'') +``` + +⚡⚡⚡ + +| col1 | col2 | col3 | +| ---- | ---- | ---- | +| | | | +| | | | + +* 1 +* 2 +* 3 +', '2025-12-15 15:33:16', null); diff --git a/backend/plugin/notice/sql/mysql/init_snowflake.sql b/backend/plugin/notice/sql/mysql/init_snowflake.sql new file mode 100644 index 00000000..2720de27 --- /dev/null +++ b/backend/plugin/notice/sql/mysql/init_snowflake.sql @@ -0,0 +1,18 @@ +insert into sys_notice (id, title, type, status, content, created_time, updated_time) +values (2112248797756129280, 'hahahahahaahahaha', 0, 1, '你好😄 + +``` +print(''fba yyds'') +``` + +⚡⚡⚡ + +| col1 | col2 | col3 | +| ---- | ---- | ---- | +| | | | +| | | | + +* 1 +* 2 +* 3 +', '2025-12-15 15:33:16', null); diff --git a/backend/plugin/notice/sql/postgresql/init.sql b/backend/plugin/notice/sql/postgresql/init.sql new file mode 100644 index 00000000..f78a810b --- /dev/null +++ b/backend/plugin/notice/sql/postgresql/init.sql @@ -0,0 +1,20 @@ +insert into sys_notice (id, title, type, status, content, created_time, updated_time) +values (1, 'hahahahahaahahaha', 0, 1, '你好😄 + +``` +print(''fba yyds'') +``` + +⚡⚡⚡ + +| col1 | col2 | col3 | +| ---- | ---- | ---- | +| | | | +| | | | + +* 1 +* 2 +* 3 +', '2025-12-15 15:33:16', null); + +select setval(pg_get_serial_sequence('sys_notice', 'id'),coalesce(max(id), 0) + 1, true) from sys_notice; diff --git a/backend/plugin/notice/sql/postgresql/init_snowflake.sql b/backend/plugin/notice/sql/postgresql/init_snowflake.sql new file mode 100644 index 00000000..2720de27 --- /dev/null +++ b/backend/plugin/notice/sql/postgresql/init_snowflake.sql @@ -0,0 +1,18 @@ +insert into sys_notice (id, title, type, status, content, created_time, updated_time) +values (2112248797756129280, 'hahahahahaahahaha', 0, 1, '你好😄 + +``` +print(''fba yyds'') +``` + +⚡⚡⚡ + +| col1 | col2 | col3 | +| ---- | ---- | ---- | +| | | | +| | | | + +* 1 +* 2 +* 3 +', '2025-12-15 15:33:16', null);