• 服务地址

    hzero-generator

    功能说明

    组件扫描:扫描前端工程中的权限按钮,值集,多语言与api数据
    权限刷新:刷新对应模块下的权限集
    数据导出:导出模块化的菜单权限、值集与多语言数据

    准备环境

    搭建临时表

    利用组件扫描扫描出来的数据默认存放在临时表中,因此需要创建临时表

    mysql:

    SET NAMES utf8mb4;
    SET FOREIGN_KEY_CHECKS = 0;
    
    -- ----------------------------
    -- Table structure for hgen_ui_api
    -- ----------------------------
    DROP TABLE IF EXISTS `hgen_ui_api`;
    CREATE TABLE `hgen_ui_api`  (
      `ui_api_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '表ID,主键,供其他表做外键',
      `ui_route` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '页面路由',
      `ui_comp_id` bigint(20) NULL DEFAULT NULL COMMENT '按钮组件ID',
      `path` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'API路径',
      `method` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'HTTP方法',
      `api_level` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'API层级',
      `service_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'API所属服务',
      `creation_date` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
      `created_by` bigint(20) NOT NULL DEFAULT -1,
      `last_updated_by` bigint(20) NOT NULL DEFAULT -1,
      `last_update_date` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
      PRIMARY KEY (`ui_api_id`) USING BTREE,
      INDEX `hiam_ui_api_n1`(`ui_route`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 8099 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'UI页面API' ROW_FORMAT = Dynamic;
    
    -- ----------------------------
    -- Table structure for hgen_ui_component
    -- ----------------------------
    DROP TABLE IF EXISTS `hgen_ui_component`;
    CREATE TABLE `hgen_ui_component`  (
      `ui_comp_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '表ID,主键,供其他表做外键',
      `ui_route` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '页面路由',
      `comp_code` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '组件编码',
      `description` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '描述',
      `comp_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '组件类型:button/lov/prompt',
      `creation_date` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
      `created_by` bigint(20) NOT NULL DEFAULT -1,
      `last_updated_by` bigint(20) NOT NULL DEFAULT -1,
      `last_update_date` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
      PRIMARY KEY (`ui_comp_id`) USING BTREE,
      UNIQUE INDEX `hiam_ui_component_u1`(`ui_route`, `comp_code`, `comp_type`) USING BTREE
    ) ENGINE = InnoDB AUTO_INCREMENT = 24252 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = 'UI组件' ROW_FORMAT = Dynamic;
    
    SET FOREIGN_KEY_CHECKS = 1;
    

    sqlserver:

    -- ----------------------------
    -- Table structure for hgen_ui_api
    -- ----------------------------
    IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[hgen_ui_api]') AND type IN ('U'))
    	DROP TABLE [dbo].[hgen_ui_api]
    GO
    
    CREATE TABLE [dbo].[hgen_ui_api] (
      [ui_api_id] int  IDENTITY(1,1) NOT NULL,
      [ui_route] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [ui_comp_id] bigint  NULL,
      [path] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [method] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [api_level] nvarchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [service_name] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [creation_date] datetime2(0) DEFAULT (getdate()) NOT NULL,
      [created_by] bigint DEFAULT ((0)) NOT NULL,
      [last_updated_by] bigint DEFAULT ((0)) NOT NULL,
      [last_update_date] datetime2(0) DEFAULT (getdate()) NOT NULL
    )
    GO
    
    ALTER TABLE [dbo].[hgen_ui_api] SET (LOCK_ESCALATION = TABLE)
    GO
    -- ----------------------------
    -- Table structure for hgen_ui_component
    -- ----------------------------
    IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[hgen_ui_component]') AND type IN ('U'))
    	DROP TABLE [dbo].[hgen_ui_component]
    GO
    
    CREATE TABLE [dbo].[hgen_ui_component] (
      [ui_comp_id] int  IDENTITY(1,1) NOT NULL,
      [ui_route] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [comp_code] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [description] nvarchar(128) COLLATE SQL_Latin1_General_CP1_CI_AS  NULL,
      [comp_type] nvarchar(30) COLLATE SQL_Latin1_General_CP1_CI_AS  NOT NULL,
      [creation_date] datetime2(0) DEFAULT (getdate()) NOT NULL,
      [created_by] bigint DEFAULT ((0)) NOT NULL,
      [last_updated_by] bigint DEFAULT ((0)) NOT NULL,
      [last_update_date] datetime2(0) DEFAULT (getdate()) NOT NULL
    )
    GO
    
    ALTER TABLE [dbo].[hgen_ui_component] SET (LOCK_ESCALATION = TABLE)
    GO
    -- ----------------------------
    -- Indexes structure for table hgen_ui_api
    -- ----------------------------
    CREATE NONCLUSTERED INDEX [hiam_ui_api_n1]
    ON [dbo].[hgen_ui_api] (
      [ui_route] ASC
    )
    GO
    -- ----------------------------
    -- Primary Key structure for table hgen_ui_api
    -- ----------------------------
    ALTER TABLE [dbo].[hgen_ui_api] ADD CONSTRAINT [PK__hgen_ui___26D4D68101AD334C] PRIMARY KEY CLUSTERED ([ui_api_id])
    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
    ON [PRIMARY]
    GO
    -- ----------------------------
    -- Primary Key structure for table hgen_ui_component
    -- ----------------------------
    ALTER TABLE [dbo].[hgen_ui_component] ADD CONSTRAINT [PK__hgen_ui___F86837B480A336F7] PRIMARY KEY CLUSTERED ([ui_comp_id])
    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)  
    ON [PRIMARY]
    GO
    

    临时表可放在任意库中,由于只是作为刷新权限集与导出数据的中间表,建议创建一个临时库用来存放临时表,此demo以hzero_generator库为例

    配置数据库

    在application.yml文件下配置:

    # mysql
    spring:
      datasource:
        dynamic:
          primary: gen
          datasource:
            gen:
              driver-class-name: com.mysql.jdbc.Driver
              url: ${SPRING_DATASOURCE_URL:jdbc:mysql://db.hzero.org:3306?useUnicode=true&characterEncoding=UTF-8&useSSL=false}
              username: ${SPRING_DATASOURCE_USERNAME:hzero}
              password: ${SPRING_DATASOURCE_PASSWORD:hzero}
    
    scan:
      tool:
        # 临时表所在库
        temporary: hzero_generator
        # 权限表所在库
        permission: hzero_platform
        # 服务路由表所在库
        service: hzero_admin
    

    组件扫描

    1. 将前端工程的路径录入输入框
    2. 选择菜单层级与需要扫描的模块
    3. 点击右侧组件扫描下按钮扫描对应数据

    ps:扫描权限按钮要在扫描API之前进行扫描,否则在刷新权限集的时候无法将api与权限按钮绑定

    刷新权限集

    此功能将页面扫描出来的权限按钮维护到对应菜单的权限集下,将api,lov维护到对应菜单的默认权限集下

    1. 选择需要刷新的菜单,然后点击刷新权限集按钮即可。
    2. 刷新成功后可检查对应菜单下的权限集有无新增的数据。

    数据导出

    1. 选择需要导出数据的菜单,然后点击数据导出下需要导出的数据即可得到打包后的excel文件

    差异多语言导出

    1. 选择需要导出数据的菜单,然后点击数据导出下的导出差异多语言,即可导出页面多语言组件与平台多语言差异的部分。

    2. 点击全部差异多语言可导出全部模块的差异多语言数据。

    3. 拿到导出的文件,利用后端数据工具中的数据导入功能即可将多语言数据导入到环境中。

    ps: 差异多语言的英文描述默认取的中文,需要手动修改;目前只支持导出前端页面上新增的多语言数据