From df2e47342b0a73745d6384715e74d23194b204ea Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Tue, 14 Oct 2025 00:23:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(gencode):=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E5=9D=97=E7=9A=84=E5=A4=9A?= =?UTF-8?q?=E5=A4=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(backend): 重构代码生成服务层和控制器层逻辑 feat(backend): 添加SQL模板文件后缀 fix(backend): 修复用户服务中的用户名空值检查 style(backend): 优化导入和代码格式 refactor(frontend): 重构代码生成前端组件和API fix(frontend): 修复用户信息表单的可选字段 feat(frontend): 添加Python和SQL图标资源 style(frontend): 调整样式和布局 chore: 更新依赖版本和配置文件 docs: 更新注释和文档内容 --- .gitignore | 1 - ...change_config_value_from_string_to_json.py | 419 +++++ .../v1/module_generator/gencode/controller.py | 12 +- .../api/v1/module_generator/gencode/crud.py | 9 +- .../api/v1/module_generator/gencode/schema.py | 9 - .../v1/module_generator/gencode/service.py | 8 +- backend/app/api/v1/module_system/user/crud.py | 2 +- .../app/api/v1/module_system/user/schema.py | 3 +- .../app/api/v1/module_system/user/service.py | 4 + backend/app/config/setting.py | 25 +- backend/app/utils/gen_util.py | 1 - backend/app/utils/jinja2_template_util.py | 2 +- backend/requirements.txt | 2 +- backend/templates/sql/{sql.j2 => sql.sql.j2} | 0 frontend/src/api/generator/gencode.ts | 152 +- frontend/src/api/system/user.ts | 30 +- frontend/src/assets/icons/python.svg | 1 + frontend/src/assets/icons/sql.svg | 1 + frontend/src/styles/index.scss | 2 +- frontend/src/views/current/profile.vue | 25 +- .../views/gencode/backcode/codegen/index.vue | 1325 -------------- .../backcode/components/basicInfoForm.vue | 48 - .../backcode/components/createTable.vue | 46 - .../gencode/backcode/components/editTable.vue | 235 --- .../backcode/components/genInfoForm.vue | 424 ----- .../backcode/components/importTable.vue | 139 -- frontend/src/views/gencode/backcode/index.vue | 1587 ++++++++++++++--- frontend/vite.config.ts | 3 +- 28 files changed, 1913 insertions(+), 2602 deletions(-) create mode 100644 backend/app/alembic/versions/d5460b04e5ce_change_config_value_from_string_to_json.py rename backend/templates/sql/{sql.j2 => sql.sql.j2} (100%) create mode 100644 frontend/src/assets/icons/python.svg create mode 100644 frontend/src/assets/icons/sql.svg delete mode 100644 frontend/src/views/gencode/backcode/codegen/index.vue delete mode 100644 frontend/src/views/gencode/backcode/components/basicInfoForm.vue delete mode 100644 frontend/src/views/gencode/backcode/components/createTable.vue delete mode 100644 frontend/src/views/gencode/backcode/components/editTable.vue delete mode 100644 frontend/src/views/gencode/backcode/components/genInfoForm.vue delete mode 100644 frontend/src/views/gencode/backcode/components/importTable.vue diff --git a/.gitignore b/.gitignore index 886ff0b4..42e34b5f 100755 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,6 @@ backend/venv backend/logs backend/*.db backend/site -backend/app/alembic/versions/* frontend/__pycache__ frontend/.vscode diff --git a/backend/app/alembic/versions/d5460b04e5ce_change_config_value_from_string_to_json.py b/backend/app/alembic/versions/d5460b04e5ce_change_config_value_from_string_to_json.py new file mode 100644 index 00000000..366ccbbd --- /dev/null +++ b/backend/app/alembic/versions/d5460b04e5ce_change_config_value_from_string_to_json.py @@ -0,0 +1,419 @@ +"""'Change config_value from String to JSON' + +Revision ID: d5460b04e5ce +Revises: +Create Date: 2025-10-08 15:38:49.199390 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import sqlite + +# revision identifiers, used by Alembic. +revision: str = 'd5460b04e5ce' +down_revision: Union[str, None] = None +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('ix_system_dict_data_creator_id', table_name='system_dict_data') + op.drop_table('system_dict_data') + op.drop_index('ix_app_job_creator_id', table_name='app_job') + op.drop_table('app_job') + op.drop_index('ix_gen_table_column_creator_id', table_name='gen_table_column') + op.drop_table('gen_table_column') + op.drop_index('ix_system_position_creator_id', table_name='system_position') + op.drop_table('system_position') + op.drop_table('system_role_depts') + op.drop_table('system_role_menus') + op.drop_table('system_user_positions') + op.drop_index('ix_app_myapp_creator_id', table_name='app_myapp') + op.drop_table('app_myapp') + op.drop_index('ix_system_dict_type_creator_id', table_name='system_dict_type') + op.drop_table('system_dict_type') + op.drop_table('app_job_log') + op.drop_index('ix_system_role_creator_id', table_name='system_role') + op.drop_table('system_role') + op.drop_index('ix_system_users_creator_id', table_name='system_users') + op.drop_index('ix_system_users_dept_id', table_name='system_users') + op.drop_table('system_users') + op.drop_index('ix_system_log_creator_id', table_name='system_log') + op.drop_table('system_log') + op.drop_index('ix_system_menu_parent_id', table_name='system_menu') + op.drop_table('system_menu') + op.drop_index('ix_system_notice_creator_id', table_name='system_notice') + op.drop_table('system_notice') + op.drop_index('ix_system_dept_parent_id', table_name='system_dept') + op.drop_table('system_dept') + op.drop_index('ix_app_ai_mcp_creator_id', table_name='app_ai_mcp') + op.drop_table('app_ai_mcp') + op.drop_index('ix_system_param_creator_id', table_name='system_param') + op.drop_table('system_param') + op.drop_index('ix_gen_demo_creator_id', table_name='gen_demo') + op.drop_table('gen_demo') + op.drop_table('system_user_roles') + op.drop_index('ix_gen_table_creator_id', table_name='gen_table') + op.drop_table('gen_table') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('gen_table', + sa.Column('table_name', sa.VARCHAR(length=200), nullable=True), + sa.Column('table_comment', sa.VARCHAR(length=500), nullable=True), + sa.Column('sub_table_name', sa.VARCHAR(length=64), nullable=True), + sa.Column('sub_table_fk_name', sa.VARCHAR(length=64), nullable=True), + sa.Column('class_name', sa.VARCHAR(length=100), nullable=True), + sa.Column('tpl_category', sa.VARCHAR(length=200), nullable=True), + sa.Column('tpl_web_type', sa.VARCHAR(length=30), nullable=True), + sa.Column('package_name', sa.VARCHAR(length=100), nullable=True), + sa.Column('module_name', sa.VARCHAR(length=30), nullable=True), + sa.Column('business_name', sa.VARCHAR(length=30), nullable=True), + sa.Column('function_name', sa.VARCHAR(length=100), nullable=True), + sa.Column('function_author', sa.VARCHAR(length=100), nullable=True), + sa.Column('gen_type', sa.VARCHAR(length=1), nullable=True), + sa.Column('gen_path', sa.VARCHAR(length=200), nullable=True), + sa.Column('options', sa.VARCHAR(length=1000), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_gen_table_creator_id', 'gen_table', ['creator_id'], unique=False) + op.create_table('system_user_roles', + sa.Column('user_id', sa.INTEGER(), nullable=False), + sa.Column('role_id', sa.INTEGER(), nullable=False), + sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['user_id'], ['system_users.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('user_id', 'role_id') + ) + op.create_table('gen_demo', + sa.Column('name', sa.VARCHAR(length=64), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_gen_demo_creator_id', 'gen_demo', ['creator_id'], unique=False) + op.create_table('system_param', + sa.Column('config_name', sa.VARCHAR(length=500), nullable=False), + sa.Column('config_key', sa.VARCHAR(length=500), nullable=False), + sa.Column('config_value', sa.VARCHAR(length=500), nullable=True), + sa.Column('config_type', sa.BOOLEAN(), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('config_key'), + sa.UniqueConstraint('config_name') + ) + op.create_index('ix_system_param_creator_id', 'system_param', ['creator_id'], unique=False) + op.create_table('app_ai_mcp', + sa.Column('name', sa.VARCHAR(length=50), nullable=False), + sa.Column('type', sa.INTEGER(), nullable=False), + sa.Column('url', sa.VARCHAR(length=255), nullable=True), + sa.Column('command', sa.VARCHAR(length=255), nullable=True), + sa.Column('args', sa.VARCHAR(length=255), nullable=True), + sa.Column('env', sqlite.JSON(), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_app_ai_mcp_creator_id', 'app_ai_mcp', ['creator_id'], unique=False) + op.create_table('system_dept', + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('name', sa.VARCHAR(length=40), nullable=False), + sa.Column('order', sa.INTEGER(), nullable=False), + sa.Column('code', sa.VARCHAR(length=20), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('parent_id', sa.INTEGER(), nullable=True), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['parent_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_system_dept_parent_id', 'system_dept', ['parent_id'], unique=False) + op.create_table('system_notice', + sa.Column('notice_title', sa.VARCHAR(length=50), nullable=False), + sa.Column('notice_type', sa.VARCHAR(length=50), nullable=False), + sa.Column('notice_content', sa.TEXT(), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_system_notice_creator_id', 'system_notice', ['creator_id'], unique=False) + op.create_table('system_menu', + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('name', sa.VARCHAR(length=50), nullable=False), + sa.Column('type', sa.INTEGER(), nullable=False), + sa.Column('order', sa.INTEGER(), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('permission', sa.VARCHAR(length=100), nullable=True), + sa.Column('icon', sa.VARCHAR(length=50), nullable=True), + sa.Column('route_name', sa.VARCHAR(length=100), nullable=True), + sa.Column('route_path', sa.VARCHAR(length=200), nullable=True), + sa.Column('component_path', sa.VARCHAR(length=200), nullable=True), + sa.Column('redirect', sa.VARCHAR(length=200), nullable=True), + sa.Column('hidden', sa.BOOLEAN(), nullable=False), + sa.Column('keep_alive', sa.BOOLEAN(), nullable=False), + sa.Column('always_show', sa.BOOLEAN(), nullable=False), + sa.Column('title', sa.VARCHAR(length=50), nullable=True), + sa.Column('params', sqlite.JSON(), nullable=True), + sa.Column('affix', sa.BOOLEAN(), nullable=False), + sa.Column('parent_id', sa.INTEGER(), nullable=True), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['parent_id'], ['system_menu.id'], ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_system_menu_parent_id', 'system_menu', ['parent_id'], unique=False) + op.create_table('system_log', + sa.Column('type', sa.INTEGER(), nullable=False), + sa.Column('request_path', sa.VARCHAR(length=255), nullable=False), + sa.Column('request_method', sa.VARCHAR(length=10), nullable=False), + sa.Column('request_payload', sa.TEXT(), nullable=True), + sa.Column('request_ip', sa.VARCHAR(length=50), nullable=True), + sa.Column('login_location', sa.VARCHAR(length=255), nullable=True), + sa.Column('request_os', sa.VARCHAR(length=64), nullable=True), + sa.Column('request_browser', sa.VARCHAR(length=64), nullable=True), + sa.Column('response_code', sa.INTEGER(), nullable=False), + sa.Column('response_json', sa.TEXT(), nullable=True), + sa.Column('process_time', sa.VARCHAR(length=20), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_system_log_creator_id', 'system_log', ['creator_id'], unique=False) + op.create_table('system_users', + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('username', sa.VARCHAR(length=32), nullable=False), + sa.Column('password', sa.VARCHAR(length=255), nullable=False), + sa.Column('name', sa.VARCHAR(length=32), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('mobile', sa.VARCHAR(length=20), nullable=True), + sa.Column('email', sa.VARCHAR(length=64), nullable=True), + sa.Column('gender', sa.VARCHAR(length=1), nullable=True), + sa.Column('avatar', sa.VARCHAR(length=500), nullable=True), + sa.Column('is_superuser', sa.BOOLEAN(), nullable=False), + sa.Column('last_login', sa.DATETIME(), nullable=True), + sa.Column('dept_id', sa.INTEGER(), nullable=True), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['dept_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('email'), + sa.UniqueConstraint('mobile'), + sa.UniqueConstraint('username') + ) + op.create_index('ix_system_users_dept_id', 'system_users', ['dept_id'], unique=False) + op.create_index('ix_system_users_creator_id', 'system_users', ['creator_id'], unique=False) + op.create_table('system_role', + sa.Column('name', sa.VARCHAR(length=40), nullable=False), + sa.Column('code', sa.VARCHAR(length=20), nullable=True), + sa.Column('order', sa.INTEGER(), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('data_scope', sa.INTEGER(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('code'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_system_role_creator_id', 'system_role', ['creator_id'], unique=False) + op.create_table('app_job_log', + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('job_name', sa.VARCHAR(length=64), nullable=False), + sa.Column('job_group', sa.VARCHAR(length=64), nullable=False), + sa.Column('job_executor', sa.VARCHAR(length=64), nullable=False), + sa.Column('invoke_target', sa.VARCHAR(length=500), nullable=False), + sa.Column('job_args', sa.VARCHAR(length=255), nullable=True), + sa.Column('job_kwargs', sa.VARCHAR(length=255), nullable=True), + sa.Column('job_trigger', sa.VARCHAR(length=255), nullable=True), + sa.Column('job_message', sa.VARCHAR(length=500), nullable=True), + sa.Column('exception_info', sa.VARCHAR(length=2000), nullable=True), + sa.Column('job_id', sa.INTEGER(), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('create_time', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['job_id'], ['app_job.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('system_dict_type', + sa.Column('dict_name', sa.VARCHAR(length=100), nullable=False), + sa.Column('dict_type', sa.VARCHAR(length=100), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('dict_name'), + sa.UniqueConstraint('dict_type') + ) + op.create_index('ix_system_dict_type_creator_id', 'system_dict_type', ['creator_id'], unique=False) + op.create_table('app_myapp', + sa.Column('name', sa.VARCHAR(length=64), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('access_url', sa.VARCHAR(length=500), nullable=False), + sa.Column('icon_url', sa.VARCHAR(length=300), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_app_myapp_creator_id', 'app_myapp', ['creator_id'], unique=False) + op.create_table('system_user_positions', + sa.Column('user_id', sa.INTEGER(), nullable=False), + sa.Column('position_id', sa.INTEGER(), nullable=False), + sa.ForeignKeyConstraint(['position_id'], ['system_position.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['user_id'], ['system_users.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('user_id', 'position_id') + ) + op.create_table('system_role_menus', + sa.Column('role_id', sa.INTEGER(), nullable=False), + sa.Column('menu_id', sa.INTEGER(), nullable=False), + sa.ForeignKeyConstraint(['menu_id'], ['system_menu.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('role_id', 'menu_id') + ) + op.create_table('system_role_depts', + sa.Column('role_id', sa.INTEGER(), nullable=False), + sa.Column('dept_id', sa.INTEGER(), nullable=False), + sa.ForeignKeyConstraint(['dept_id'], ['system_dept.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['role_id'], ['system_role.id'], onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('role_id', 'dept_id') + ) + op.create_table('system_position', + sa.Column('name', sa.VARCHAR(length=40), nullable=False), + sa.Column('order', sa.INTEGER(), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + op.create_index('ix_system_position_creator_id', 'system_position', ['creator_id'], unique=False) + op.create_table('gen_table_column', + sa.Column('column_name', sa.VARCHAR(length=200), nullable=True), + sa.Column('column_comment', sa.VARCHAR(length=500), nullable=True), + sa.Column('column_type', sa.VARCHAR(length=100), nullable=True), + sa.Column('python_type', sa.VARCHAR(length=500), nullable=True), + sa.Column('python_field', sa.VARCHAR(length=200), nullable=True), + sa.Column('is_pk', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_increment', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_required', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_unique', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_insert', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_edit', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_list', sa.VARCHAR(length=1), nullable=True), + sa.Column('is_query', sa.VARCHAR(length=1), nullable=True), + sa.Column('query_type', sa.VARCHAR(length=200), nullable=True), + sa.Column('html_type', sa.VARCHAR(length=200), nullable=True), + sa.Column('dict_type', sa.VARCHAR(length=200), nullable=True), + sa.Column('sort', sa.INTEGER(), nullable=True), + sa.Column('table_id', sa.INTEGER(), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['table_id'], ['gen_table.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_gen_table_column_creator_id', 'gen_table_column', ['creator_id'], unique=False) + op.create_table('app_job', + sa.Column('name', sa.VARCHAR(length=64), nullable=True), + sa.Column('jobstore', sa.VARCHAR(length=64), nullable=True), + sa.Column('executor', sa.VARCHAR(length=64), nullable=True), + sa.Column('trigger', sa.VARCHAR(length=64), nullable=False), + sa.Column('trigger_args', sa.TEXT(), nullable=True), + sa.Column('func', sa.TEXT(), nullable=False), + sa.Column('args', sa.TEXT(), nullable=True), + sa.Column('kwargs', sa.TEXT(), nullable=True), + sa.Column('coalesce', sa.BOOLEAN(), nullable=True), + sa.Column('max_instances', sa.INTEGER(), nullable=True), + sa.Column('start_date', sa.VARCHAR(length=64), nullable=True), + sa.Column('end_date', sa.VARCHAR(length=64), nullable=True), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_app_job_creator_id', 'app_job', ['creator_id'], unique=False) + op.create_table('system_dict_data', + sa.Column('dict_sort', sa.INTEGER(), nullable=False), + sa.Column('dict_label', sa.VARCHAR(length=100), nullable=False), + sa.Column('dict_value', sa.VARCHAR(length=100), nullable=False), + sa.Column('dict_type', sa.VARCHAR(length=100), nullable=False), + sa.Column('status', sa.BOOLEAN(), nullable=False), + sa.Column('css_class', sa.VARCHAR(length=100), nullable=True), + sa.Column('list_class', sa.VARCHAR(length=100), nullable=True), + sa.Column('is_default', sa.BOOLEAN(), nullable=False), + sa.Column('dict_type_id', sa.INTEGER(), nullable=True), + sa.Column('creator_id', sa.INTEGER(), nullable=True), + sa.Column('id', sa.INTEGER(), nullable=False), + sa.Column('description', sa.TEXT(), nullable=True), + sa.Column('created_at', sa.DATETIME(), nullable=True), + sa.Column('updated_at', sa.DATETIME(), nullable=True), + sa.ForeignKeyConstraint(['creator_id'], ['system_users.id'], onupdate='CASCADE', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['dict_type_id'], ['system_dict_type.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('ix_system_dict_data_creator_id', 'system_dict_data', ['creator_id'], unique=False) + # ### end Alembic commands ### diff --git a/backend/app/api/v1/module_generator/gencode/controller.py b/backend/app/api/v1/module_generator/gencode/controller.py index ede1a5d2..6eb2c69e 100644 --- a/backend/app/api/v1/module_generator/gencode/controller.py +++ b/backend/app/api/v1/module_generator/gencode/controller.py @@ -12,7 +12,7 @@ from app.common.request import PaginationService from app.api.v1.module_system.auth.schema import AuthSchema from app.common.constant import RET from .param import GenTableQueryParam -from .schema import GenTableDeleteSchema, GenTableSchema, GenTableOutSchema +from .schema import GenTableSchema, GenTableOutSchema from .service import GenTableColumnService, GenTableService from app.utils.common_util import bytes2file_response from app.core.logger import logger @@ -47,7 +47,7 @@ async def get_gen_db_table_list_controller( @GenRouter.post("/import", summary="导入表结构", description="导入表结构") async def import_gen_table_controller( - table_names: List[str] = Query(..., description="表名列表"), + table_names: List[str] = Body(..., description="表名列表"), auth: AuthSchema = Depends(AuthPermission(["generator:gencode:import"])), ) -> JSONResponse: add_gen_table_list = await GenTableService.get_gen_db_table_list_by_name_service(auth, table_names) @@ -70,7 +70,7 @@ async def gen_table_detail_controller( @GenRouter.post("/create", summary="创建表结构", description="创建表结构") async def create_table_controller( - sql: str = Query(..., description="SQL语句:CREATE TABLE user_demo (\n id INTEGER NOT NULL PRIMARY KEY,\n username VARCHAR(64) NOT NULL UNIQUE,\n);"), + sql: str = Body(..., description="SQL语句:CREATE TABLE user_demo (\n id INTEGER NOT NULL PRIMARY KEY,\n username VARCHAR(64) NOT NULL UNIQUE,\n);"), auth: AuthSchema = Depends(AuthPermission(["generator:gencode:create"])), ) -> JSONResponse: result = await GenTableService.create_table_service(auth, sql) @@ -92,17 +92,17 @@ async def update_gen_table_controller( @GenRouter.delete("/delete", summary="删除业务表信息", description="删除业务表信息") async def delete_gen_table_controller( - data: GenTableDeleteSchema = Body(..., description="业务表ID列表"), + ids: List[int] = Body(..., description="业务表ID列表"), auth: AuthSchema = Depends(AuthPermission(["generator:gencode:delete"])) ) -> JSONResponse: - result = await GenTableService.delete_gen_table_service(auth, data) + result = await GenTableService.delete_gen_table_service(auth, ids) logger.info('删除业务表信息成功') return SuccessResponse(msg="删除业务表信息成功", data=result) @GenRouter.patch("/batch/output", summary="批量生成代码", description="批量生成代码") async def batch_gen_code_controller( - table_names: List[str] = Query(..., description="表名列表"), + table_names: List[str] = Body(..., description="表名列表"), auth: AuthSchema = Depends(AuthPermission(["generator:gencode:operate"])) ) -> StreamResponse: # 检查table_names是否为空 diff --git a/backend/app/api/v1/module_generator/gencode/crud.py b/backend/app/api/v1/module_generator/gencode/crud.py index c56a6775..dd5e00d8 100644 --- a/backend/app/api/v1/module_generator/gencode/crud.py +++ b/backend/app/api/v1/module_generator/gencode/crud.py @@ -15,7 +15,6 @@ from .model import GenTableModel, GenTableColumnModel from .schema import ( GenTableSchema, GenTableOutSchema, - GenTableDeleteSchema, GenTableColumnSchema, GenTableColumnOutSchema, GenTableColumnDeleteSchema, @@ -137,12 +136,12 @@ class GenTableCRUD(CRUDBase[GenTableModel, GenTableSchema, GenTableSchema]): await self.db.commit() return edit_model - async def delete_gen_table(self, data: GenTableDeleteSchema) -> None: + async def delete_gen_table(self, ids: List[int]) -> None: """ 删除 """ await self.db.execute( - delete(GenTableModel).where(GenTableModel.id.in_(data.table_ids)) + delete(GenTableModel).where(GenTableModel.id.in_(ids)) ) await self.db.flush() @@ -459,10 +458,10 @@ class GenTableColumnCRUD(CRUDBase[GenTableColumnModel, GenTableColumnSchema, Gen """更新业务表字段""" return await self.update(id=id, data=data) - async def delete_gen_table_column_by_table_id_dao(self, data: GenTableDeleteSchema) -> None: + async def delete_gen_table_column_by_table_id_dao(self, table_ids: List[int]) -> None: """根据业务表ID批量删除""" # 先查询出这些表ID对应的所有字段ID - query = select(GenTableColumnModel.id).where(GenTableColumnModel.table_id.in_(data.table_ids)) + query = select(GenTableColumnModel.id).where(GenTableColumnModel.table_id.in_(table_ids)) result = await self.db.execute(query) column_ids = [row[0] for row in result.fetchall()] diff --git a/backend/app/api/v1/module_generator/gencode/schema.py b/backend/app/api/v1/module_generator/gencode/schema.py index dbd85170..80f2ea20 100644 --- a/backend/app/api/v1/module_generator/gencode/schema.py +++ b/backend/app/api/v1/module_generator/gencode/schema.py @@ -108,15 +108,6 @@ class GenTableOutSchema(GenTableSchema, BaseSchema): return values -class GenTableDeleteSchema(BaseModel): - """ - 删除代码生成业务表模型 - """ - model_config = ConfigDict(alias_generator=to_camel) - - table_ids: List[int] = Field(..., description='需要删除的代码生成业务表ID列表') - - class GenTableColumnSchema(BaseModel): """ 代码生成业务表字段创建模型 diff --git a/backend/app/api/v1/module_generator/gencode/service.py b/backend/app/api/v1/module_generator/gencode/service.py index aac8d474..f5d28bb3 100644 --- a/backend/app/api/v1/module_generator/gencode/service.py +++ b/backend/app/api/v1/module_generator/gencode/service.py @@ -16,7 +16,7 @@ from app.api.v1.module_system.auth.schema import AuthSchema from app.utils.common_util import CamelCaseUtil from app.utils.gen_util import GenUtils from app.utils.jinja2_template_util import Jinja2TemplateInitializerUtil, Jinja2TemplateUtil -from .schema import GenTableSchema, GenTableOutSchema, GenTableOutSchema, GenTableDeleteSchema, GenTableColumnSchema, GenTableColumnOutSchema, GenTableColumnDeleteSchema +from .schema import GenTableSchema, GenTableOutSchema, GenTableOutSchema, GenTableColumnSchema, GenTableColumnOutSchema, GenTableColumnDeleteSchema from .param import GenTableQueryParam from .crud import GenTableColumnCRUD, GenTableCRUD @@ -211,13 +211,13 @@ class GenTableService: raise CustomException(msg='业务表不存在') @classmethod - async def delete_gen_table_service(cls, auth: AuthSchema, data: GenTableDeleteSchema) -> None: + async def delete_gen_table_service(cls, auth: AuthSchema, ids: List[int]) -> None: """删除业务表信息""" try: # 先删除相关的字段信息 - await GenTableColumnCRUD(auth=auth).delete_gen_table_column_by_table_id_dao(data) + await GenTableColumnCRUD(auth=auth).delete_gen_table_column_by_table_id_dao(ids) # 再删除表信息 - await GenTableCRUD(auth=auth).delete_gen_table(data) + await GenTableCRUD(auth=auth).delete_gen_table(ids) except Exception as e: raise CustomException(msg=f'删除失败: {str(e)}') diff --git a/backend/app/api/v1/module_system/user/crud.py b/backend/app/api/v1/module_system/user/crud.py index 72dd9937..bc28973d 100644 --- a/backend/app/api/v1/module_system/user/crud.py +++ b/backend/app/api/v1/module_system/user/crud.py @@ -6,7 +6,7 @@ from datetime import datetime from app.core.base_crud import CRUDBase from .model import UserModel -from .schema import UserCreateSchema,UserForgetPasswordSchema,UserUpdateSchema +from .schema import UserCreateSchema, UserForgetPasswordSchema, UserUpdateSchema from ..role.crud import RoleCRUD from ..position.crud import PositionCRUD diff --git a/backend/app/api/v1/module_system/user/schema.py b/backend/app/api/v1/module_system/user/schema.py index 077b7a64..fa3d4249 100644 --- a/backend/app/api/v1/module_system/user/schema.py +++ b/backend/app/api/v1/module_system/user/schema.py @@ -65,7 +65,7 @@ class UserCreateSchema(CurrentUserUpdateSchema): """新增""" model_config = ConfigDict(from_attributes=True) - username: str = Field(default=..., max_length=32, description="用户名") + username: Optional[str] = Field(default=None, max_length=32, description="用户名") password: Optional[str] = Field(default=None, max_length=128, description="密码哈希值") status: bool = Field(default=True, description="是否可用") is_superuser: bool = Field(default=False, description="是否超管") @@ -82,6 +82,7 @@ class UserUpdateSchema(UserCreateSchema): last_login: Optional[DateTimeStr] = Field(default=None, description="最后登录时间") + class UserOutSchema(UserCreateSchema, BaseSchema): """响应""" model_config = ConfigDict(arbitrary_types_allowed=True, from_attributes=True) diff --git a/backend/app/api/v1/module_system/user/service.py b/backend/app/api/v1/module_system/user/service.py index c2f6c38d..ad2107e0 100644 --- a/backend/app/api/v1/module_system/user/service.py +++ b/backend/app/api/v1/module_system/user/service.py @@ -69,6 +69,8 @@ class UserService: @classmethod async def create_user_service(cls, data: UserCreateSchema, auth: AuthSchema) -> Dict: + if not data.username: + raise CustomException(msg="用户名不能为空") # 检查用户名是否存在 user = await UserCRUD(auth).get_by_username_crud(username=data.username) if user: @@ -97,6 +99,8 @@ class UserService: @classmethod async def update_user_service(cls, id: int, data: UserUpdateSchema, auth: AuthSchema) -> Dict: + if not data.username: + raise CustomException(msg="用户名不能为空") # 检查用户是否存在 user = await UserCRUD(auth).get_by_id_crud(id=id) if not user: diff --git a/backend/app/config/setting.py b/backend/app/config/setting.py index 8b762aed..f320a2c0 100755 --- a/backend/app/config/setting.py +++ b/backend/app/config/setting.py @@ -162,29 +162,6 @@ class Settings(BaseSettings): GZIP_MIN_SIZE: int = 1000 # 最小压缩大小(字节) GZIP_COMPRESS_LEVEL: int = 9 # 压缩级别(1-9) - # # ================================================= # - # # ***************** 演示模型配置 ***************** # - # # ================================================= # - # DEMO_ENABLE: bool # 是否开启演示模式 - # DEMO_WHITE_LIST_PATH: List[str] = [ # 演示白名单 - # "/api/v1/system/auth/login", - # "/api/v1/system/auth/token/refresh", - # "/api/v1/system/auth/captcha/get", - # "/api/v1/system/auth/logout", - # "/api/v1/system/config/info", - # "/api/v1/system/user/current/info", - # "/api/v1/system/notice/available", - # ] - # DEMO_BLACK_LIST_PATH: List[str] = [ # 演示黑名单 - # "/auth/login" - # ] - # DEMO_IP_WHITE_LIST: List[str] = [ # 演示白名单IP - # "127.0.0.1", - # "117.10.167.220", - # "223.104.208.30", - # "42.80.102.171" - # ] - # ================================================= # # ***************** 静态文件配置 ***************** # # ================================================= # @@ -202,7 +179,7 @@ class Settings(BaseSettings): # ================================================= # # ***************** 动态文件配置 ***************** # # ================================================= # - UPLOAD_FILE_PATH: Path = BASE_DIR.joinpath('static/upload') # 上传目录 + UPLOAD_FILE_PATH: Path = Path('static/upload') # 上传目录 UPLOAD_MACHINE: str = 'A' # 上传机器标识 ALLOWED_EXTENSIONS: list[str] = [ # 允许的文件类型 # 图片 diff --git a/backend/app/utils/gen_util.py b/backend/app/utils/gen_util.py index 40b58f92..e1068358 100644 --- a/backend/app/utils/gen_util.py +++ b/backend/app/utils/gen_util.py @@ -12,7 +12,6 @@ from app.api.v1.module_generator.gencode.schema import ( GenTableBaseSchema, GenTableSchema, GenTableOutSchema, - GenTableDeleteSchema, GenTableColumnSchema, GenTableColumnOutSchema, GenTableColumnDeleteSchema diff --git a/backend/app/utils/jinja2_template_util.py b/backend/app/utils/jinja2_template_util.py index 749bf00d..d909ba16 100644 --- a/backend/app/utils/jinja2_template_util.py +++ b/backend/app/utils/jinja2_template_util.py @@ -224,7 +224,7 @@ class Jinja2TemplateUtil: # Vue相关模板 f'{use_web_type}/api.ts.j2', # SQL脚本模板 - 'sql/sql.j2', + 'sql/sql.sql.j2', ] if category == GenConstant.TPL_CRUD: templates.append(f'{use_web_type}/index.vue.j2') diff --git a/backend/requirements.txt b/backend/requirements.txt index 57dc09ac..564f8c8b 100755 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -22,7 +22,7 @@ pydantic-settings==2.5.2 # 配置设置 psutil==6.1.0 # 系统信息 python-multipart==0.0.9 # request.form() 对表单进行「解析」时安装 greenlet==3.1.1 # 协程框架 -bcrypt==4.0.1 # 密码加密解析 +bcrypt==4.3.0 # 密码加密解析 itsdangerous==2.2.0 # 用于安全处理各种数据,如密码、密钥等 aiofiles==24.1.0 # 文件操作 redis==5.2.1 # redis 同步操作数据库(用户celery配套使用)redis 异步操作数据库 redis已经完全具备了aioredis的功能,无需重复安全,且aioredis已经不再维护也不兼容3.10+的版本 diff --git a/backend/templates/sql/sql.j2 b/backend/templates/sql/sql.sql.j2 similarity index 100% rename from backend/templates/sql/sql.j2 rename to backend/templates/sql/sql.sql.j2 diff --git a/frontend/src/api/generator/gencode.ts b/frontend/src/api/generator/gencode.ts index 540b1d05..3d4ae402 100644 --- a/frontend/src/api/generator/gencode.ts +++ b/frontend/src/api/generator/gencode.ts @@ -4,7 +4,7 @@ const API_PATH = "/generator/gencode"; const GencodeAPI = { // 查询生成表数据 - listTable(query: TablePageQuery) { + listTable(query: GenTableQueryParam) { return request>>({ url: `${API_PATH}/list`, method: 'get', @@ -13,25 +13,20 @@ const GencodeAPI = { }, // 查询db数据库列表 - listDbTable(query: TablePageQuery) { - return request>>({ + listDbTable(query: GenTableQueryParam) { + return request>>({ url: `${API_PATH}/db/list`, method: 'get', params: query }) }, - // 导入表 - 将数组转换为适合FastAPI解析的格式 + // 导入表 importTable(table_names: string[]) { - // 构建符合FastAPI期望的查询字符串 - let queryString = ''; - table_names.forEach((name, index) => { - queryString += `${index === 0 ? '?' : '&'}table_names=${encodeURIComponent(name)}`; - }); - return request({ - url: `${API_PATH}/import${queryString}`, - method: 'post' + url: `${API_PATH}/import`, + method: 'post', + data: table_names }) }, @@ -48,25 +43,25 @@ const GencodeAPI = { return request({ url: `${API_PATH}/create`, method: 'post', - params: { sql } + data: sql }) }, - // 修改代码生成信息 - updateGenTable(table_id: number, body: GenTableSchema) { + // 更新表信息 + updateTable(data: GenTableSchema, table_id: number) { return request({ url: `${API_PATH}/update/${table_id}`, method: 'put', - data: body, + data }) }, // 删除表数据 - deleteTable(data: GenTableDeleteSchema) { + deleteTable(table_ids: number[]) { return request({ url: `${API_PATH}/delete`, method: 'delete', - data + data: table_ids }) }, @@ -75,7 +70,7 @@ const GencodeAPI = { return request({ url: `${API_PATH}/batch/output`, method: 'patch', - params: { table_names }, + data: table_names, responseType: 'blob' }) }, @@ -89,9 +84,9 @@ const GencodeAPI = { }, // 预览生成代码 - previewTable(table_id: number) { - return request>({ - url: `${API_PATH}/preview/${table_id}`, + previewTable(id: number) { + return request>>({ + url: `${API_PATH}/preview/${id}`, method: 'get' }) }, @@ -118,6 +113,15 @@ export interface GeneratorPreviewVO { } /** 数据表分页查询参数 */ +export interface GenTableQueryParam { + page_no: number; + page_size: number; + table_name?: string; + table_comment?: string; + start_time?: string; + end_time?: string; +} + export interface TablePageQuery extends PageQuery { /** 表名称 */ table_name?: string; @@ -146,27 +150,27 @@ export interface GenTableOutVO { /** 主键 */ id?: number; /** 表名称 */ - table_name: string; + table_name?: string; /** 表描述 */ - table_comment: string; + table_comment?: string; /** 关联子表的表名 */ sub_table_name?: string; /** 子表关联的外键名 */ - sub_table_fk_name: string; + sub_table_fk_name?: string; /** 实体类名称 */ - class_name: string; + class_name?: string; /** 使用的模板(crud单表操作 tree树表操作) */ tpl_category?: string; /** 前端模板类型(element-ui模版 element-plus模版) */ tpl_web_type?: string; /** 生成包路径 */ - package_name: string; + package_name?: string; /** 生成模块名 */ - module_name: string; + module_name?: string; /** 生成业务名 */ - business_name: string; + business_name?: string; /** 生成功能名 */ - function_name: string; + function_name?: string; /** 生成功能作者 */ function_author?: string; /** 生成代码方式(0zip压缩包 1自定义路径) */ @@ -191,6 +195,24 @@ export interface GenTableOutVO { tree?: boolean; /** 是否为单表 */ crud?: boolean; + /** 表描述 */ + description?: string; + /** 列列表 */ + columns?: GenTableColumnOutSchema[]; + /** 参数选项 */ + params?: GenTableOptionModel; +} + +/** 表选项模型 */ +export interface GenTableOptionModel { + /** 所属父级分类 */ + parent_menu_id?: number; + /** 树编码 */ + tree_code?: string; + /** 树名称 */ + tree_name?: string; + /** 树父编码 */ + tree_parent_code?: string; } /** 代码生成业务表模型 */ @@ -214,11 +236,11 @@ export interface GenTableColumnSchema { /** 列描述 */ column_comment?: string; /** 列类型 */ - column_type: string; + column_type?: string; /** PYTHON类型 */ python_type?: string; /** PYTHON字段名 */ - python_field: string; + python_field?: string; /** 是否主键(1是) */ is_pk?: string; /** 是否自增(1是) */ @@ -238,9 +260,9 @@ export interface GenTableColumnSchema { /** 查询方式(等于、不等于、大于、小于、范围) */ query_type?: string; /** 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件) */ - html_type: string; + html_type?: string; /** 字典类型 */ - dict_type: string; + dict_type?: string; /** 排序 */ sort?: number; /** 功能描述 */ @@ -273,12 +295,6 @@ export interface GenTableColumnOutSchema extends GenTableColumnSchema { usable_column?: boolean; } -/** 删除代码生成业务表模型 */ -export interface GenTableDeleteSchema { - /** 需要删除的代码生成业务表ID列表 */ - table_ids: number[]; -} - /** 表详情查询结果 */ export interface GenTableDetailResult { /** 表信息 */ @@ -288,3 +304,59 @@ export interface GenTableDetailResult { /** 所有表信息 */ tables: GenTableOutVO[]; } + +/** + * 数据库表基本信息接口 + */ +export interface DatabaseTable { + database_name?: string; + table_name?: string; + table_comment?: string; + table_type?: string; +} + +/** + * 表列基本信息接口 + */ +export interface TableColumn { + column_name: string; + column_comment: string; +} + +/** + * 表基本信息接口 + */ +export interface TableInfo { + table_name?: string; + table_comment?: string; + columns?: TableColumn[]; +} + +/** + * 字典选项接口 + */ +export interface DictOption { + dict_type: string; + dict_name: string; +} + +/** + * 导入表查询表单数据接口 + */ +export interface ImportTableQueryForm { + page_no: number; + page_size: number; + table_name?: string; + table_comment?: string; +} + +/** + * 基本信息表单数据接口 + */ +export interface BasicInfoFormData { + table_name?: string; + table_comment?: string; + class_name?: string; + function_author?: string; + remark?: string; +} diff --git a/frontend/src/api/system/user.ts b/frontend/src/api/system/user.ts index 07756ce6..caae4fd6 100644 --- a/frontend/src/api/system/user.ts +++ b/frontend/src/api/system/user.ts @@ -220,17 +220,17 @@ export interface positionSelectorType { export interface InfoFormState { id?: number; - name: string; - gender: number; - mobile: string; - email: string; - username: string; - dept_name: string; - dept: deptTreeType; - positions: positionSelectorType[]; - roles: roleSelectorType[]; - avatar: string; - created_at: string; + name?: string; + gender?: number; + mobile?: string; + email?: string; + username?: string; + dept_name?: string; + dept?: deptTreeType; + positions?: positionSelectorType[]; + roles?: roleSelectorType[]; + avatar?: string; + created_at?: string; } export interface PasswordFormState { @@ -262,3 +262,11 @@ export interface UserForm { status?: boolean; description?: string; } + +export interface CurrentUserFormState { + name?: string; + gender?: number; + mobile?: string; + email?: string; + avatar?: string; +} diff --git a/frontend/src/assets/icons/python.svg b/frontend/src/assets/icons/python.svg new file mode 100644 index 00000000..d9bab518 --- /dev/null +++ b/frontend/src/assets/icons/python.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/assets/icons/sql.svg b/frontend/src/assets/icons/sql.svg new file mode 100644 index 00000000..dc4a3a82 --- /dev/null +++ b/frontend/src/assets/icons/sql.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/styles/index.scss b/frontend/src/styles/index.scss index cfe6f902..65e25f9c 100644 --- a/frontend/src/styles/index.scss +++ b/frontend/src/styles/index.scss @@ -116,6 +116,6 @@ html.sidebar-color-blue .layout-mix .layout__sidebar--left .el-menu { // 分页区域 .el-pagination { justify-content: flex-end; - // margin-top: 1px; + // margin-top: 16px; } } diff --git a/frontend/src/views/current/profile.vue b/frontend/src/views/current/profile.vue index 34756f88..d712062e 100644 --- a/frontend/src/views/current/profile.vue +++ b/frontend/src/views/current/profile.vue @@ -44,7 +44,7 @@ {{ infoFormState.name }} - {{infoFormState.roles.map(item => item.name).join('、')}} + {{infoFormState.roles?.map(item => item.name).join('、')}} @@ -68,7 +68,7 @@ 部门 - {{ infoFormState.dept.name }} + {{ infoFormState.dept?.name }} - {{infoFormState.positions.map(item => item.name).join('、')}} + {{infoFormState.positions?.map(item => item.name).join('、')}}