@Override
    @Transactional(rollbackFor = Exception.class)
    public List<Long> createCodegenList(Long userId, CodegenCreateListReqVO reqVO) {
        List<Long> ids = new ArrayList<>(reqVO.getTableNames().size());
        // 遍历添加。虽然效率会低一点，但是没必要做成完全批量，因为不会这么大量
        reqVO.getTableNames().forEach(tableName -> ids.add(createCodegen(userId, reqVO.getDataSourceConfigId(), tableName)));
        return ids;
    }
@Test
    public void testCreateCodegenList() {
        // 准备参数
        Long userId = randomLongId();
        CodegenCreateListReqVO reqVO = randomPojo(CodegenCreateListReqVO.class,
                o -> o.setDataSourceConfigId(1L).setTableNames(Collections.singletonList("t_yunai")));
        // mock 方法（TableInfo）
        TableInfo tableInfo = mock(TableInfo.class);
        when(databaseTableService.getTable(eq(1L), eq("t_yunai")))
                .thenReturn(tableInfo);
        when(tableInfo.getComment()).thenReturn("芋艿");
        // mock 方法（TableInfo fields）
        TableField field01 = mock(TableField.class);
        when(field01.getComment()).thenReturn("主键");
        TableField field02 = mock(TableField.class);
        when(field02.getComment()).thenReturn("名字");
        List<TableField> fields = Arrays.asList(field01, field02);
        when(tableInfo.getFields()).thenReturn(fields);
        // mock 方法（CodegenTableDO）
        CodegenTableDO table = randomPojo(CodegenTableDO.class);
        when(codegenBuilder.buildTable(same(tableInfo))).thenReturn(table);
        // mock 方法（AdminUserRespDTO）
        AdminUserRespDTO user = randomPojo(AdminUserRespDTO.class, o -> o.setNickname("芋头"));
        when(userApi.getUser(eq(userId))).thenReturn(user);
        // mock 方法（CodegenColumnDO）
        List<CodegenColumnDO> columns = randomPojoList(CodegenColumnDO.class);
        when(codegenBuilder.buildColumns(eq(table.getId()), same(fields)))
                .thenReturn(columns);
        // mock 方法（CodegenProperties）
        when(codegenProperties.getFrontType()).thenReturn(CodegenFrontTypeEnum.VUE3.getType());

        // 调用
        List<Long> result = codegenService.createCodegenList(userId, reqVO);
        // 断言
        assertEquals(1, result.size());
        // 断言（CodegenTableDO）
        CodegenTableDO dbTable = codegenTableMapper.selectList().get(0);
        assertPojoEquals(table, dbTable);
        assertEquals(1L, dbTable.getDataSourceConfigId());
        assertEquals(CodegenSceneEnum.ADMIN.getScene(), dbTable.getScene());
        assertEquals(CodegenFrontTypeEnum.VUE3.getType(), dbTable.getFrontType());
        assertEquals("芋头", dbTable.getAuthor());
        // 断言（CodegenColumnDO）
        List<CodegenColumnDO> dbColumns = codegenColumnMapper.selectList();
        assertEquals(columns.size(), dbColumns.size());
        assertTrue(dbColumns.get(0).getPrimaryKey());
        for (int i = 0; i < dbColumns.size(); i++) {
            assertPojoEquals(columns.get(i), dbColumns.get(i));
        }
    }