You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by ni...@apache.org on 2024/01/08 05:37:53 UTC
(incubator-paimon-webui) branch main updated: [Feature] Suport CDC job definition persistence (#99)
This is an automated email from the ASF dual-hosted git repository.
nicholasjiang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-paimon-webui.git
The following commit(s) were added to refs/heads/main by this push:
new 2388f1d [Feature] Suport CDC job definition persistence (#99)
2388f1d is described below
commit 2388f1d1324fb43b00a8b30595b34aa7b174e656
Author: yangyang zhong <35...@users.noreply.github.com>
AuthorDate: Mon Jan 8 13:37:48 2024 +0800
[Feature] Suport CDC job definition persistence (#99)
---
paimon-web-server/pom.xml | 6 +
.../web/server/controller/CatalogController.java | 2 +-
.../controller/CdcJobDefinitionController.java | 82 ++++++++
.../web/server/data/dto/CdcJobDefinitionDTO.java | 38 ++++
.../web/server/data/model/CdcJobDefinition.java | 51 +++++
.../web/server/data/result/enums/Status.java | 5 +-
.../web/server/mapper/CdcJobDefinitionMapper.java | 26 +++
.../server/service/CdcJobDefinitionService.java | 36 ++++
.../service/impl/CdcJobDefinitionServiceImpl.java | 105 ++++++++++
paimon-web-server/src/main/resources/db/ddl-h2.sql | 132 ------------
.../src/main/resources/i18n/messages.properties | 2 +
.../main/resources/i18n/messages_en_US.properties | 2 +
.../main/resources/i18n/messages_zh_CN.properties | 2 +
.../resources/mapper/CdcJobDefinitionMapper.xml | 23 +++
.../controller/CdcJobDefinitionControllerTest.java | 124 ++++++++++++
.../web/server/controller/ControllerTestBase.java | 37 ++++
.../src/test/resources/application-dev-h2.yml | 2 +-
paimon-web-ui-new/src/api/models/catalog/index.ts | 2 +-
paimon-web-ui-new/src/api/models/cdc/index.ts | 56 ++++++
.../select.ts => api/models/cdc/interface.ts} | 28 +--
.../src/components/dynamic-form/fields/select.ts | 2 +-
paimon-web-ui-new/src/form-lib/cdc/use-mysql.ts | 1 -
paimon-web-ui-new/src/form-lib/cdc/use-paimon.ts | 98 +++------
.../src/views/cdc/components/dag/index.tsx | 26 ++-
.../src/views/cdc/components/list/index.tsx | 223 +--------------------
.../src/views/cdc/components/list/use-table.ts | 120 +++++++++++
paimon-web-ui-new/src/views/cdc/index.tsx | 1 -
scripts/sql/paimon-mysql.sql | 15 ++
28 files changed, 800 insertions(+), 447 deletions(-)
diff --git a/paimon-web-server/pom.xml b/paimon-web-server/pom.xml
index 3656806..5aee2a6 100644
--- a/paimon-web-server/pom.xml
+++ b/paimon-web-server/pom.xml
@@ -217,6 +217,12 @@ under the License.
<include>static/**</include>
</includes>
</resource>
+ <resource>
+ <directory>${project.basedir}/../scripts</directory>
+ <includes>
+ <include>sql/**</include>
+ </includes>
+ </resource>
</resources>
<plugins>
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CatalogController.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CatalogController.java
index 561b863..79a54a5 100644
--- a/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CatalogController.java
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CatalogController.java
@@ -68,7 +68,7 @@ public class CatalogController {
*
* @return The list of all catalogs.
*/
- @GetMapping("/getAllCatalogs")
+ @GetMapping("/list")
public R<List<CatalogInfo>> getCatalog() {
List<CatalogInfo> catalogs = catalogService.list();
return R.succeed(catalogs);
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CdcJobDefinitionController.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CdcJobDefinitionController.java
new file mode 100644
index 0000000..94df83d
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/controller/CdcJobDefinitionController.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.controller;
+
+import org.apache.paimon.web.server.data.dto.CdcJobDefinitionDTO;
+import org.apache.paimon.web.server.data.model.CdcJobDefinition;
+import org.apache.paimon.web.server.data.result.PageR;
+import org.apache.paimon.web.server.data.result.R;
+import org.apache.paimon.web.server.service.CdcJobDefinitionService;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/** CdcJobDefinition api controller. */
+@Slf4j
+@RestController
+@RequestMapping("/api/cdc-job-definition")
+public class CdcJobDefinitionController {
+
+ private CdcJobDefinitionService cdcJobDefinitionService;
+
+ public CdcJobDefinitionController(CdcJobDefinitionService cdcJobDefinitionService) {
+ this.cdcJobDefinitionService = cdcJobDefinitionService;
+ }
+
+ @PostMapping("create")
+ public R<Void> createCdcJob(@RequestBody CdcJobDefinitionDTO cdcJobDefinitionDTO) {
+ return cdcJobDefinitionService.create(cdcJobDefinitionDTO);
+ }
+
+ @PutMapping("update")
+ public R<Void> updateCdcJob(@RequestBody CdcJobDefinitionDTO cdcJobDefinitionDTO) {
+ return cdcJobDefinitionService.update(cdcJobDefinitionDTO);
+ }
+
+ @GetMapping("list")
+ public PageR<CdcJobDefinition> listAllCdcJob(
+ @RequestParam(required = false) boolean withConfig,
+ @RequestParam long currentPage,
+ @RequestParam long pageSize) {
+ return cdcJobDefinitionService.listAll(withConfig, currentPage, pageSize);
+ }
+
+ @GetMapping("/{id}")
+ public R<CdcJobDefinition> getById(@PathVariable Integer id) {
+ CdcJobDefinition cdcJobDefinition = cdcJobDefinitionService.getById(id);
+ if (cdcJobDefinition == null) {
+ return R.failed();
+ }
+ return R.succeed(cdcJobDefinition);
+ }
+
+ @DeleteMapping("{id}")
+ public R<Void> deleteById(@PathVariable Integer id) {
+ cdcJobDefinitionService.removeById(id);
+ return R.succeed();
+ }
+}
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/dto/CdcJobDefinitionDTO.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/dto/CdcJobDefinitionDTO.java
new file mode 100644
index 0000000..d1c5b14
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/dto/CdcJobDefinitionDTO.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.data.dto;
+
+import lombok.Data;
+
+/** DTO of cdcJobDefinition . */
+@Data
+public class CdcJobDefinitionDTO {
+
+ private Integer id;
+
+ private String name;
+
+ private String description;
+
+ private Integer cdcType;
+
+ private String config;
+
+ private String createUser;
+}
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/CdcJobDefinition.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/CdcJobDefinition.java
new file mode 100644
index 0000000..0a20b99
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/model/CdcJobDefinition.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.data.model;
+
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/** Model of cdc_job_definition */
+@TableName(value = "cdc_job_definition")
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@Builder
+public class CdcJobDefinition extends BaseModel implements Serializable {
+
+ private String name;
+
+ private String description;
+
+ private Integer cdcType;
+
+ private String config;
+
+ private String createUser;
+
+ @TableLogic private boolean isDelete;
+}
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/result/enums/Status.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/result/enums/Status.java
index 15cdc43..9a28cef 100644
--- a/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/result/enums/Status.java
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/data/result/enums/Status.java
@@ -73,7 +73,10 @@ public enum Status {
TABLE_DROP_COLUMN_ERROR(10506, "table.drop.column.error"),
TABLE_AlTER_COLUMN_ERROR(10507, "table.alter.column.error"),
TABLE_DROP_ERROR(10510, "table.drop.error"),
- TABLE_RENAME_ERROR(10510, "table.rename.error");
+ TABLE_RENAME_ERROR(10511, "table.rename.error"),
+
+ CDC_JOB_EXIST_ERROR(10601, "cdc.job.exist.error"),
+ CDC_JOB_NO_EXIST_ERROR(10602, "cdc.job.not.exist.error");
private final int code;
private final String msg;
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CdcJobDefinitionMapper.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CdcJobDefinitionMapper.java
new file mode 100644
index 0000000..99385ae
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/mapper/CdcJobDefinitionMapper.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.mapper;
+
+import org.apache.paimon.web.server.data.model.CdcJobDefinition;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/** CdcJobDefinition table mapper. */
+public interface CdcJobDefinitionMapper extends BaseMapper<CdcJobDefinition> {}
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/CdcJobDefinitionService.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/CdcJobDefinitionService.java
new file mode 100644
index 0000000..9da2679
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/CdcJobDefinitionService.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.service;
+
+import org.apache.paimon.web.server.data.dto.CdcJobDefinitionDTO;
+import org.apache.paimon.web.server.data.model.CdcJobDefinition;
+import org.apache.paimon.web.server.data.result.PageR;
+import org.apache.paimon.web.server.data.result.R;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/** Cdc Job Definition Service. */
+public interface CdcJobDefinitionService extends IService<CdcJobDefinition> {
+
+ R<Void> create(CdcJobDefinitionDTO cdcJobDefinitionDTO);
+
+ PageR<CdcJobDefinition> listAll(boolean withConfig, long currentPage, long pageSize);
+
+ R<Void> update(CdcJobDefinitionDTO cdcJobDefinitionDTO);
+}
diff --git a/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/CdcJobDefinitionServiceImpl.java b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/CdcJobDefinitionServiceImpl.java
new file mode 100644
index 0000000..be3979f
--- /dev/null
+++ b/paimon-web-server/src/main/java/org/apache/paimon/web/server/service/impl/CdcJobDefinitionServiceImpl.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.service.impl;
+
+import org.apache.paimon.web.server.data.dto.CdcJobDefinitionDTO;
+import org.apache.paimon.web.server.data.model.CdcJobDefinition;
+import org.apache.paimon.web.server.data.result.PageR;
+import org.apache.paimon.web.server.data.result.R;
+import org.apache.paimon.web.server.data.result.enums.Status;
+import org.apache.paimon.web.server.mapper.CdcJobDefinitionMapper;
+import org.apache.paimon.web.server.service.CdcJobDefinitionService;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/** CdcJobDefinitionServiceImpl. */
+@Service
+public class CdcJobDefinitionServiceImpl
+ extends ServiceImpl<CdcJobDefinitionMapper, CdcJobDefinition>
+ implements CdcJobDefinitionService {
+
+ @Override
+ public R<Void> create(CdcJobDefinitionDTO cdcJobDefinitionDTO) {
+ String name = cdcJobDefinitionDTO.getName();
+ QueryWrapper<CdcJobDefinition> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("name", name);
+ if (baseMapper.exists(queryWrapper)) {
+ return R.failed(Status.CDC_JOB_EXIST_ERROR);
+ }
+ CdcJobDefinition cdcJobDefinition =
+ CdcJobDefinition.builder()
+ .name(cdcJobDefinitionDTO.getName())
+ .config(cdcJobDefinitionDTO.getConfig())
+ .cdcType(cdcJobDefinitionDTO.getCdcType())
+ .createUser(cdcJobDefinitionDTO.getCreateUser())
+ .description(cdcJobDefinitionDTO.getDescription())
+ .build();
+ baseMapper.insert(cdcJobDefinition);
+ return R.succeed();
+ }
+
+ @Override
+ public PageR<CdcJobDefinition> listAll(boolean withConfig, long currentPage, long pageSize) {
+ Page<CdcJobDefinition> page = new Page<>(currentPage, pageSize);
+ QueryWrapper<CdcJobDefinition> queryWrapper = new QueryWrapper<>();
+ queryWrapper.select(
+ "id",
+ "name",
+ "cdc_type",
+ "create_user",
+ "description",
+ "update_time",
+ "create_time");
+ if (!withConfig) {
+ queryWrapper.select(
+ "name",
+ "id",
+ "description",
+ "cdc_type",
+ "create_user",
+ "update_time",
+ "create_time");
+ }
+ Page<CdcJobDefinition> resPage = baseMapper.selectPage(page, queryWrapper);
+ return new PageR<>(resPage.getTotal(), true, resPage.getRecords());
+ }
+
+ @Override
+ public R<Void> update(CdcJobDefinitionDTO cdcJobDefinitionDTO) {
+ QueryWrapper<CdcJobDefinition> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("id", cdcJobDefinitionDTO.getId());
+ if (!baseMapper.exists(queryWrapper)) {
+ return R.failed(Status.CDC_JOB_NO_EXIST_ERROR);
+ }
+ CdcJobDefinition cdcJobDefinition =
+ CdcJobDefinition.builder()
+ .name(cdcJobDefinitionDTO.getName())
+ .config(cdcJobDefinitionDTO.getConfig())
+ .cdcType(cdcJobDefinitionDTO.getCdcType())
+ .createUser(cdcJobDefinitionDTO.getCreateUser())
+ .description(cdcJobDefinitionDTO.getDescription())
+ .build();
+ cdcJobDefinition.setId(cdcJobDefinitionDTO.getId());
+ baseMapper.updateById(cdcJobDefinition);
+ return R.succeed();
+ }
+}
diff --git a/paimon-web-server/src/main/resources/db/ddl-h2.sql b/paimon-web-server/src/main/resources/db/ddl-h2.sql
deleted file mode 100644
index c1bd1d2..0000000
--- a/paimon-web-server/src/main/resources/db/ddl-h2.sql
+++ /dev/null
@@ -1,132 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements. See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License. You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-CREATE TABLE if not exists `user`
-(
- `id` int(11) NOT NULL PRIMARY KEY COMMENT 'ID',
- `username` varchar(50) NOT NULL COMMENT 'username',
- `password` varchar(50) NULL DEFAULT NULL COMMENT 'password',
- `nickname` varchar(50) NULL DEFAULT NULL COMMENT 'nickname',
- `user_type` int NOT NULL DEFAULT 0 COMMENT 'login type (0:LOCAL,1:LDAP)',
- `url` varchar(100) NULL DEFAULT NULL COMMENT 'avatar url',
- `mobile` varchar(20) NULL DEFAULT NULL COMMENT 'mobile phone',
- `email` varchar(100) NULL DEFAULT NULL COMMENT 'email',
- `enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
- `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `tenant`
-(
- `id` int(11) NOT NULL PRIMARY KEY COMMENT 'ID',
- `name` varchar(64) NULL DEFAULT NULL COMMENT 'tenant name',
- `description` varchar(255) NULL DEFAULT NULL COMMENT 'tenant description',
- `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `user_tenant`
-(
- `id` int(11) NOT NULL PRIMARY KEY COMMENT 'ID',
- `user_id` int(11) NOT NULL COMMENT 'user id',
- `tenant_id` int(11) NOT NULL COMMENT 'tenant id',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) ENGINE = InnoDB;
-
-CREATE TABLE if not exists `sys_role`
-(
- `id` int(11) not null primary key comment 'id',
- `role_name` varchar(30) not null comment 'role name',
- `role_key` varchar(100) not null comment 'role key',
- `sort` int(4) not null comment 'sort',
- `enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
- `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
- `remark` varchar(500) default null comment 'remark',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
-
-CREATE TABLE if not exists `sys_menu`
-(
- `id` int(11) not null primary key comment 'id',
- `menu_name` varchar(50) not null comment 'menu name',
- `parent_id` int(11) default 0 comment 'parent id',
- `sort` int(4) default 0 comment 'sort',
- `path` varchar(200) default '' comment 'route path',
- `query` varchar(255) default null comment 'route params',
- `is_cache` int(1) default 0 comment 'is cache(0:cache 1:no_cache)',
- `type` char(1) default '' comment 'menu type(M:directory C:menu F:button)',
- `visible` char(1) default 0 comment 'is visible(0:display 1:hide)',
- `component` varchar(255) default null comment 'component path',
- `is_frame` int(1) default 0 comment 'is frame',
- `enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'is enable',
- `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
- `perms` varchar(100) default null comment 'menu perms',
- `icon` varchar(100) default '#' comment 'menu icon',
- `remark` varchar(500) default '' comment 'remark',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
-
-CREATE TABLE if not exists `user_role`
-(
- `id` int(11) not null primary key comment 'id',
- `user_id` int(11) not null comment 'user id',
- `role_id` int(11) not null comment 'role id',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time',
- unique key `idx_user_role` (`user_id`, `role_id`)
-) engine = innodb;
-
-CREATE TABLE if not exists `role_menu`
-(
- `id` int(11) not null primary key comment 'id',
- `role_id` int(11) not null comment 'role id',
- `menu_id` int(11) not null comment 'menu id',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time',
- unique key `idx_role_menu` (`role_id`, `menu_id`)
-) engine = innodb;
-
-CREATE TABLE if not exists `catalog`
-(
- id int not null comment 'id'
- primary key,
- catalog_type varchar(50) not null comment 'catalog type',
- catalog_name varchar(100) not null comment 'catalog name',
- warehouse varchar(200) not null comment 'warehouse',
- hive_uri varchar(200) null comment 'hive uri',
- hive_conf_dir varchar(100) null comment 'catalog name',
- is_delete tinyint(1) default 0 not null comment 'is delete',
- create_time datetime default CURRENT_TIMESTAMP null comment 'create time',
- update_time datetime default CURRENT_TIMESTAMP null comment 'update time',
- options varchar(512) null
-) engine = innodb;
-
-
-
-CREATE TABLE if not exists `databases`
-(
- `id` int(11) not null primary key comment 'id',
- `database_name` varchar(50) not null comment 'database name',
- `catalog_id` int(11) not null comment 'catalog id',
- `description` varchar(200) comment 'description',
- `is_delete` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'is delete',
- `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
- `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time'
-) engine = innodb;
diff --git a/paimon-web-server/src/main/resources/i18n/messages.properties b/paimon-web-server/src/main/resources/i18n/messages.properties
index 37610ec..0ca9822 100644
--- a/paimon-web-server/src/main/resources/i18n/messages.properties
+++ b/paimon-web-server/src/main/resources/i18n/messages.properties
@@ -48,3 +48,5 @@ table.remove.option.error=Exception calling Paimon Catalog API to remove an opti
table.alter.column.error=Exception calling Paimon Catalog API to alter a column.
table.drop.error=Exception calling Paimon Catalog API to drop a table.
table.rename.error=Exception calling Paimon Catalog API to rename a table.
+cdc.job.exist.error=Paimon CDC job is exist.
+cdc.job.not.exist.error=Paimon CDC job is not exist.
diff --git a/paimon-web-server/src/main/resources/i18n/messages_en_US.properties b/paimon-web-server/src/main/resources/i18n/messages_en_US.properties
index ca74509..6c247c1 100644
--- a/paimon-web-server/src/main/resources/i18n/messages_en_US.properties
+++ b/paimon-web-server/src/main/resources/i18n/messages_en_US.properties
@@ -37,3 +37,5 @@ catalog.name.exist=This catalog name {0} is exist
catalog.create.error=An exception is returned when calling the Paimon API to create a Catalog.
database.name.exist=This database name {0} is exist.
database.create.error=An exception is returned when calling the Paimon API to create a Database.
+cdc.job.exist.error=Paimon CDC job is exist.
+cdc.job.not.exist.error=Paimon CDC job is not exist.
diff --git a/paimon-web-server/src/main/resources/i18n/messages_zh_CN.properties b/paimon-web-server/src/main/resources/i18n/messages_zh_CN.properties
index 6ceb2d8..b96a554 100644
--- a/paimon-web-server/src/main/resources/i18n/messages_zh_CN.properties
+++ b/paimon-web-server/src/main/resources/i18n/messages_zh_CN.properties
@@ -33,3 +33,5 @@ role.key.exist=\u6B64\u89D2\u8272\u5173\u952E\u5B57{0}\u5DF2\u4F7F\u7528
menu.in.used=\u6B64\u83DC\u5355\u6B63\u5728\u4F7F\u7528\u4E2D
menu.name.exist=\u6B64\u83DC\u5355\u540D\u79F0\u5DF2\u5B58\u5728:{0}
menu.path.invalid=\u6B64\u83DC\u5355\u8DEF\u5F84\u65E0\u6548:{0}
+cdc.job.exist.error=paimon cdc\u4f5c\u4e1a\u5df2\u5b58\u5728
+cdc.job.not.exist.error=paimon cdc\u4f5c\u4e1a\u4e0d\u5b58\u5728
diff --git a/paimon-web-server/src/main/resources/mapper/CdcJobDefinitionMapper.xml b/paimon-web-server/src/main/resources/mapper/CdcJobDefinitionMapper.xml
new file mode 100644
index 0000000..84e898f
--- /dev/null
+++ b/paimon-web-server/src/main/resources/mapper/CdcJobDefinitionMapper.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.paimon.web.server.mapper.CdcJobDefinitionMapper">
+
+ <resultMap id="BaseResultMap" type="org.apache.paimon.web.server.data.model.CdcJobDefinition">
+ <result property="id" column="id" jdbcType="INTEGER"/>
+ <result property="name" column="name" jdbcType="VARCHAR"/>
+ <result property="description" column="description" jdbcType="VARCHAR"/>
+ <result property="cdcType" column="cdc_type" jdbcType="INTEGER"/>
+ <result property="config" column="config" jdbcType="VARCHAR"/>
+ <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
+ <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+ <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ id,name,description,
+ cdc_type,config,create_user,
+ create_time,update_time
+ </sql>
+</mapper>
diff --git a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CdcJobDefinitionControllerTest.java b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CdcJobDefinitionControllerTest.java
new file mode 100644
index 0000000..ad4d734
--- /dev/null
+++ b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/CdcJobDefinitionControllerTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.web.server.controller;
+
+import org.apache.paimon.web.server.data.dto.CdcJobDefinitionDTO;
+import org.apache.paimon.web.server.data.model.CdcJobDefinition;
+import org.apache.paimon.web.server.data.result.PageR;
+import org.apache.paimon.web.server.data.result.R;
+import org.apache.paimon.web.server.util.ObjectMapperUtils;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
+import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/** Test for CdcJobDefinitionController . */
+@SpringBootTest
+@AutoConfigureMockMvc
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+public class CdcJobDefinitionControllerTest extends ControllerTestBase {
+
+ private static final String cdcJobDefinitionPath = "/api/cdc-job-definition";
+
+ private CdcJobDefinitionDTO cdcJobDefinitionDto() {
+ CdcJobDefinitionDTO cdcJobDefinitionDTO = new CdcJobDefinitionDTO();
+ cdcJobDefinitionDTO.setName("1");
+ cdcJobDefinitionDTO.setCdcType(0);
+ cdcJobDefinitionDTO.setConfig("d");
+ cdcJobDefinitionDTO.setDescription("d");
+ return cdcJobDefinitionDTO;
+ }
+
+ @Test
+ @Order(1)
+ public void testCreateCdcJob() throws Exception {
+ MockHttpServletResponse response =
+ mockMvc.perform(
+ MockMvcRequestBuilders.post(cdcJobDefinitionPath + "/create")
+ .cookie(cookie)
+ .content(ObjectMapperUtils.toJSON(cdcJobDefinitionDto()))
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .accept(MediaType.APPLICATION_JSON_VALUE))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andDo(MockMvcResultHandlers.print())
+ .andReturn()
+ .getResponse();
+ checkMvcResult(response, 200);
+ }
+
+ @Test
+ @Order(2)
+ public void testGetCdcJobDefinition() throws Exception {
+ MockHttpServletResponse response =
+ mockMvc.perform(
+ MockMvcRequestBuilders.get(cdcJobDefinitionPath + "/list")
+ .cookie(cookie)
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .accept(MediaType.APPLICATION_JSON_VALUE)
+ .param("currentPage", "1")
+ .param("pageSize", "10")
+ .param("withConfig", "true"))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andDo(MockMvcResultHandlers.print())
+ .andReturn()
+ .getResponse();
+ PageR<CdcJobDefinition> result =
+ getPageR(response, new TypeReference<PageR<CdcJobDefinition>>() {});
+ CdcJobDefinitionDTO cdcJobDefinitionDTO = cdcJobDefinitionDto();
+ assertEquals(1, result.getTotal());
+ MockHttpServletResponse getCdcJobDefinitionResponse =
+ mockMvc.perform(
+ MockMvcRequestBuilders.get(
+ cdcJobDefinitionPath
+ + "/"
+ + result.getData().get(0).getId())
+ .cookie(cookie)
+ .contentType(MediaType.APPLICATION_JSON_VALUE)
+ .accept(MediaType.APPLICATION_JSON_VALUE))
+ .andExpect(MockMvcResultMatchers.status().isOk())
+ .andDo(MockMvcResultHandlers.print())
+ .andReturn()
+ .getResponse();
+ R<CdcJobDefinition> getResult =
+ getR(getCdcJobDefinitionResponse, new TypeReference<R<CdcJobDefinition>>() {});
+ CdcJobDefinition cdcJobDefinition = getResult.getData();
+ CdcJobDefinition realRdcJobDefinition =
+ CdcJobDefinition.builder()
+ .name(cdcJobDefinitionDTO.getName())
+ .config(cdcJobDefinitionDTO.getConfig())
+ .cdcType(cdcJobDefinitionDTO.getCdcType())
+ .createUser(cdcJobDefinitionDTO.getCreateUser())
+ .description(cdcJobDefinitionDTO.getDescription())
+ .build();
+ assertEquals(realRdcJobDefinition.getName(), cdcJobDefinition.getName());
+ assertEquals(realRdcJobDefinition.getDescription(), cdcJobDefinition.getDescription());
+ assertEquals(realRdcJobDefinition.getConfig(), cdcJobDefinition.getConfig());
+ }
+}
diff --git a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
index 6a0f833..4cd6e14 100644
--- a/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
+++ b/paimon-web-server/src/test/java/org/apache/paimon/web/server/controller/ControllerTestBase.java
@@ -23,11 +23,13 @@ import org.apache.paimon.web.server.data.dto.DatabaseDTO;
import org.apache.paimon.web.server.data.dto.LoginDTO;
import org.apache.paimon.web.server.data.dto.TableDTO;
import org.apache.paimon.web.server.data.model.TableColumn;
+import org.apache.paimon.web.server.data.result.PageR;
import org.apache.paimon.web.server.data.result.R;
import org.apache.paimon.web.server.util.ObjectMapperUtils;
import org.apache.paimon.web.server.util.PaimonDataType;
import org.apache.paimon.web.server.util.StringUtils;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.junit.jupiter.api.AfterEach;
@@ -237,4 +239,39 @@ public class ControllerTestBase {
String result = response.getContentAsString();
return ObjectMapperUtils.fromJSON(result, R.class);
}
+
+ protected R<?> getR(MockHttpServletResponse response) throws Exception {
+ String result = response.getContentAsString();
+ return ObjectMapperUtils.fromJSON(result, R.class);
+ }
+
+ protected <T> R<T> getR(MockHttpServletResponse response, TypeReference<R<T>> typeReference)
+ throws Exception {
+ String result = response.getContentAsString();
+ return ObjectMapperUtils.fromJSON(result, typeReference);
+ }
+
+ protected PageR<?> getPageR(MockHttpServletResponse response) throws Exception {
+ String result = response.getContentAsString();
+ return ObjectMapperUtils.fromJSON(result, PageR.class);
+ }
+
+ protected <T> PageR<T> getPageR(
+ MockHttpServletResponse response, TypeReference<PageR<T>> typeReference)
+ throws Exception {
+ String result = response.getContentAsString();
+ return ObjectMapperUtils.fromJSON(result, typeReference);
+ }
+
+ protected void checkMvcResult(MockHttpServletResponse response, int exceptedStatus)
+ throws Exception {
+ R<?> r = getR(response);
+ assertEquals(exceptedStatus, r.getCode());
+ }
+
+ protected void checkMvcPageResult(MockHttpServletResponse response, boolean exceptedStatus)
+ throws Exception {
+ PageR<?> pageR = getPageR(response);
+ assertEquals(pageR.isSuccess(), exceptedStatus);
+ }
}
diff --git a/paimon-web-server/src/test/resources/application-dev-h2.yml b/paimon-web-server/src/test/resources/application-dev-h2.yml
index 12a5608..139dc2b 100644
--- a/paimon-web-server/src/test/resources/application-dev-h2.yml
+++ b/paimon-web-server/src/test/resources/application-dev-h2.yml
@@ -25,7 +25,7 @@ spring:
sql:
init:
data-locations: classpath:sql/paimon-mysql.sql
- continue-on-error: true
+ continue-on-error: false
username: root
password: root
mode: always
diff --git a/paimon-web-ui-new/src/api/models/catalog/index.ts b/paimon-web-ui-new/src/api/models/catalog/index.ts
index 08ad4f4..268f404 100644
--- a/paimon-web-ui-new/src/api/models/catalog/index.ts
+++ b/paimon-web-ui-new/src/api/models/catalog/index.ts
@@ -40,7 +40,7 @@ export * from './types'
* # Get all catalog
*/
export const getAllCatalogs = () => {
- return httpRequest.get<unknown, ResponseOptions<Catalog[]>>('/catalog/getAllCatalogs')
+ return httpRequest.get<unknown, ResponseOptions<Catalog[]>>('/catalog/list')
}
/**
diff --git a/paimon-web-ui-new/src/api/models/cdc/index.ts b/paimon-web-ui-new/src/api/models/cdc/index.ts
new file mode 100644
index 0000000..98f2385
--- /dev/null
+++ b/paimon-web-ui-new/src/api/models/cdc/index.ts
@@ -0,0 +1,56 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License. */
+
+
+import type { CdcJobDefinition } from './interface'
+import httpRequest from '@/api/request'
+export * from './interface'
+
+/**
+ * # Create cdc job definition
+ */
+export const createCdcJob = (cdcJobDefinition: CdcJobDefinition) => {
+ return httpRequest.post('/cdc-job-definition/create', cdcJobDefinition)
+}
+
+/**
+ * # Update cdc job definition
+ */
+export const updateCdcJob = (cdcJobDefinition: CdcJobDefinition) => {
+ return httpRequest.put(`/cdc-job-definition/update`, cdcJobDefinition)
+}
+
+/**
+ * # List all cdc job definitions
+ */
+export const listAllCdcJob = (withConfig: boolean, currentPage: number, pageSize: number) => {
+ return httpRequest.get('/cdc-job-definition/list', { withConfig, currentPage, pageSize })
+}
+
+/**
+ * # Get cdc job definition detail
+ */
+export const getCdcJobDefinition = (id: number) => {
+ return httpRequest.get(`/cdc-job-definition/${id}`)
+}
+
+/**
+ * # Delete cdc job definition
+ */
+export const deleteCdcJobDefinition = (id: number) => {
+ return httpRequest.delete(`/cdc-job-definition/${id}`)
+}
diff --git a/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts b/paimon-web-ui-new/src/api/models/cdc/interface.ts
similarity index 60%
copy from paimon-web-ui-new/src/components/dynamic-form/fields/select.ts
copy to paimon-web-ui-new/src/api/models/cdc/interface.ts
index fabd2db..dec7b6e 100644
--- a/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts
+++ b/paimon-web-ui-new/src/api/models/cdc/interface.ts
@@ -15,22 +15,14 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
-import { NSelect } from 'naive-ui'
-import { isFunction } from 'lodash'
-import type { IJsonItem } from '../types'
-
-export function renderSelect(
- item: IJsonItem,
- fields: { [field: string]: any }
-) {
- const { props, field, options = [] } = isFunction(item) ? item() : item
- return h(NSelect, {
- ...props,
- value: fields[field],
- onUpdateValue: (value: any) => {
- void (fields[field] = value)
- if (props?.onUpdateValue) props.onUpdateValue(value)
- },
- options: unref(options)
- })
+export interface CdcJobDefinition {
+ id?: number;
+ createTime?: string;
+ updateTime?: string;
+ name: string;
+ description?: string;
+ cdcType?: number;
+ config?: string;
+ createUser?: string;
}
+
\ No newline at end of file
diff --git a/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts b/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts
index fabd2db..de289be 100644
--- a/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts
+++ b/paimon-web-ui-new/src/components/dynamic-form/fields/select.ts
@@ -31,6 +31,6 @@ export function renderSelect(
void (fields[field] = value)
if (props?.onUpdateValue) props.onUpdateValue(value)
},
- options: unref(options)
+ options: options
})
}
diff --git a/paimon-web-ui-new/src/form-lib/cdc/use-mysql.ts b/paimon-web-ui-new/src/form-lib/cdc/use-mysql.ts
index d47eab5..823c7f2 100644
--- a/paimon-web-ui-new/src/form-lib/cdc/use-mysql.ts
+++ b/paimon-web-ui-new/src/form-lib/cdc/use-mysql.ts
@@ -21,7 +21,6 @@ export function useMYSQL(item:any) {
const { t } = useLocaleHooks()
const tabType = item.data.tabType
- console.log('item', item.data)
const data = item.data
const model = reactive({
diff --git a/paimon-web-ui-new/src/form-lib/cdc/use-paimon.ts b/paimon-web-ui-new/src/form-lib/cdc/use-paimon.ts
index 10e0daf..d8d2322 100644
--- a/paimon-web-ui-new/src/form-lib/cdc/use-paimon.ts
+++ b/paimon-web-ui-new/src/form-lib/cdc/use-paimon.ts
@@ -15,83 +15,51 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License. */
+import { getAllCatalogs } from "@/api/models/catalog"
import type { IJsonItem } from "@/components/dynamic-form/types"
+import { useCatalogStore } from "@/store/catalog"
-export function usePaimon(item:any) {
- const { t } = useLocaleHooks()
-
- const tabType = item.data.tabType
- console.log('item', item.data)
-
+export function usePaimon(item: any) {
+ const { t } = useLocaleHooks()
+ const tabType = item.data.tabType
+ let catalogOptions: any = ref([{value:1}])
+ const catalogStore = useCatalogStore()
+ catalogStore.getAllCatalogs().then(()=>{
+ catalogOptions.value = catalogStore.catalogs
+ })
const model = reactive({
warehouse: '',
- metastore: '',
- url: '',
- other_configs: '',
- database: '',
- table_name: '',
- primary_key: '',
- partition_column: '',
+ metastore: '',
+ url: '',
+ other_configs: '',
+ database: '',
+ table_name: '',
+ primary_key: '',
+ partition_column: '',
other_configs2: '',
})
- const TypeMappingOptions = [] as any
-
return {
json: [
{
- type: 'input',
- field: 'warehouse',
- name: 'Warehouse',
+ type: 'select',
+ field: 'catalog',
+ name: 'catalog',
+ span: computed(() => tabType.value === 'catalog_configuration' ? 24 : 0),
props: {
- placeholder: ''
+ placeholder: '',
},
- span: computed(() => tabType.value === 'catalog_configuration' ? 24 : 0),
- validate: {
- trigger: ['input', 'blur'],
- required: true,
- message: 'error',
- validator: (validator: any, value: string) => {
- if (!value) {
- return new Error('error')
- }
- }
- }
+ options: catalogOptions
+
},
{
- type: 'select',
- field: 'metastore',
- name: 'Metastore',
- options: TypeMappingOptions,
- span: computed(() => tabType.value === 'catalog_configuration' ? 24 : 0),
- },
- {
- type: 'input',
- field: 'url',
- name: 'Url',
- span: computed(() => tabType.value === 'catalog_configuration' ? 24 : 0),
- props: {
- placeholder: ''
- }
- },
- {
- type: 'input',
- field: 'other_configs',
- name: t('cdc.other_configs'),
- span: computed(() => tabType.value === 'catalog_configuration' ? 24 : 0),
- props: {
- placeholder: '',
- type: 'textarea',
- }
- },
- {
type: 'input',
field: 'database',
name: t('cdc.database'),
props: {
placeholder: ''
},
- span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
+ span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
validate: {
trigger: ['input', 'blur'],
required: true,
@@ -103,14 +71,14 @@ export function usePaimon(item:any) {
}
}
},
- {
+ {
type: 'input',
field: 'table_name',
name: t('cdc.table_name'),
props: {
placeholder: ''
},
- span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
+ span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
validate: {
trigger: ['input', 'blur'],
required: true,
@@ -122,11 +90,11 @@ export function usePaimon(item:any) {
}
}
},
- {
+ {
type: 'input',
field: 'primary_key',
name: t('cdc.primary_key'),
- span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
+ span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
props: {
placeholder: ''
}
@@ -135,19 +103,19 @@ export function usePaimon(item:any) {
type: 'input',
field: 'partition_column',
name: t('cdc.partition_column'),
- span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
+ span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
props: {
placeholder: ''
}
},
- {
+ {
type: 'input',
field: 'other_configs2',
name: t('cdc.other_configs'),
- span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
+ span: computed(() => tabType.value === 'synchronization_configuration' ? 24 : 0),
props: {
placeholder: '',
- type: 'textarea',
+ type: 'textarea',
}
},
] as IJsonItem[], model
diff --git a/paimon-web-ui-new/src/views/cdc/components/dag/index.tsx b/paimon-web-ui-new/src/views/cdc/components/dag/index.tsx
index 073ec6b..11ec588 100644
--- a/paimon-web-ui-new/src/views/cdc/components/dag/index.tsx
+++ b/paimon-web-ui-new/src/views/cdc/components/dag/index.tsx
@@ -20,21 +20,33 @@ import styles from './index.module.scss';
import DagCanvas from "./dag-canvas";
import { useCDCStore } from "@/store/cdc";
import type { Router } from "vue-router";
+import { createCdcJob, updateCdcJob } from "@/api/models/cdc";
export default defineComponent({
name: 'DagPage',
setup() {
const { t } = useLocaleHooks()
const CDCStore = useCDCStore()
- const title = ref('')
+ const name = ref('')
onMounted(() => {
- title.value = CDCStore.getModel.name
+ name.value = CDCStore.getModel.name
})
const dagRef = ref() as any
const handleSave = () => {
- // console.log('dagRef', dagRef.value.graph.toJSON())
- router.push({ path: '/cdc_ingestion' })
+ const editMode = CDCStore.getModel.editMode
+ if (editMode === 'edit') {
+ updateCdcJob({ id: CDCStore.getModel.id, name: name.value + "", description: CDCStore.getModel.description, cdcType: CDCStore.getModel.synchronizationType, config: JSON.stringify(dagRef.value.graph.toJSON()) })
+ .then(() => {
+ router.push({ path: '/cdc_ingestion' })
+ })
+ } else {
+ createCdcJob({ name: name.value + "", description: CDCStore.getModel.description, cdcType: CDCStore.getModel.synchronizationType, config: JSON.stringify(dagRef.value.graph.toJSON()) })
+ .then(() => {
+ router.push({ path: '/cdc_ingestion' })
+ })
+ }
+
}
const router: Router = useRouter()
@@ -49,10 +61,10 @@ export default defineComponent({
})
}
})
-
+
return {
t,
- title,
+ name,
handleSave,
dagRef,
handleJump
@@ -67,7 +79,7 @@ export default defineComponent({
<n-space align="center">
<n-icon component={Leaf} color="#2F7BEA" size="18" />
<span class={styles.title} onClick={this.handleJump}>{this.t('cdc.synchronization_job_definition')} {
- this.title ? ` - ${this.title}` : ''
+ this.name ? ` - ${this.name}` : ''
}</span>
</n-space>
<div class={styles.operation}>
diff --git a/paimon-web-ui-new/src/views/cdc/components/list/index.tsx b/paimon-web-ui-new/src/views/cdc/components/list/index.tsx
index 78deb86..21176dd 100644
--- a/paimon-web-ui-new/src/views/cdc/components/list/index.tsx
+++ b/paimon-web-ui-new/src/views/cdc/components/list/index.tsx
@@ -16,229 +16,16 @@ specific language governing permissions and limitations
under the License. */
import styles from './index.module.scss';
-import TableAction from '@/components/table-action';
-import { useCDCStore } from '@/store/cdc';
-import type { Router } from 'vue-router';
+import { useTable } from './use-table'
export default defineComponent({
name: 'ListPage',
setup() {
const { t } = useLocaleHooks()
- const router: Router = useRouter()
- const tableVariables = reactive({
- columns: [
- {
- title: computed(() => t('cdc.job_name')),
- key: 'name',
- resizable: true
- },
- {
- title: computed(() => t('cdc.synchronization_type')),
- key: 'type',
- resizable: true
- },
- {
- title: computed(() => t('cdc.job_description')),
- key: 'description',
- resizable: true
- },
- {
- title: computed(() => t('cdc.create_user')),
- key: 'create_user',
- resizable: true
- },
- {
- title: computed(() => t('cdc.create_time')),
- key: 'create_time',
- resizable: true
- },
- {
- title: computed(() => t('cdc.update_time')),
- key: 'update_time',
- resizable: true
- },
- {
- title: computed(() => t('cdc.operation')),
- key: 'actions',
- render: (row: any) =>
- h(TableAction, {
- row,
- onHandleEdit: (row) => {
- const CDCStore = useCDCStore()
- CDCStore.setModel(row)
- router.push({ path: '/cdc_ingestion/dag' })
- },
- })
- }
- ],
- data: [
- {
- name: 1,
- type: 'Single table synchronization',
- create_user: 'admin',
- cells: [
- {
- "position": {
- "x": 300,
- "y": 40
- },
- "size": {
- "width": 150,
- "height": 40
- },
- "view": "vue-shape-view",
- "shape": "custom-node",
- "ports": {
- "groups": {
- "in": {
- "position": "left",
- "attrs": {
- "circle": {
- "r": 4,
- "magnet": true,
- "stroke": "transparent",
- "strokeWidth": 1,
- "fill": "transparent"
- }
- }
- },
- "out": {
- "position": {
- "name": "right",
- "args": {
- "dx": 5
- }
- },
- "attrs": {
- "circle": {
- "r": 4,
- "magnet": true,
- "stroke": "transparent",
- "strokeWidth": 1,
- "fill": "transparent"
- }
- }
- }
- },
- "items": [
- {
- "id": "MySQL-out",
- "group": "out",
- "attrs": {
- "circle": {
- "fill": "transparent",
- "stroke": "transparent"
- }
- }
- }
- ]
- },
- "id": "MySQL",
- "data": {
- "name": "MySQL",
- "value": "MYSQL",
- "type": "INPUT",
- "host": "1",
- "port": "2",
- "username": "3",
- "password": "4",
- "other_configs": "5",
- "database": "",
- "table_name": "",
- "type_mapping": "",
- "metadata_column": "",
- "computed_column": ""
- },
- "zIndex": 1
- },
- {
- "position": {
- "x": 640,
- "y": 40
- },
- "size": {
- "width": 150,
- "height": 40
- },
- "view": "vue-shape-view",
- "shape": "custom-node",
- "ports": {
- "groups": {
- "in": {
- "position": "left",
- "attrs": {
- "circle": {
- "r": 4,
- "magnet": true,
- "stroke": "transparent",
- "strokeWidth": 1,
- "fill": "transparent"
- }
- }
- },
- "out": {
- "position": {
- "name": "right",
- "args": {
- "dx": 5
- }
- },
- "attrs": {
- "circle": {
- "r": 4,
- "magnet": true,
- "stroke": "transparent",
- "strokeWidth": 1,
- "fill": "transparent"
- }
- }
- }
- },
- "items": [
- {
- "id": "Paimon-in",
- "group": "in",
- "attrs": {
- "circle": {
- "fill": "transparent",
- "stroke": "transparent"
- }
- }
- }
- ]
- },
- "id": "Paimon",
- "data": {
- "name": "Paimon",
- "value": "PAIMON",
- "type": "OUTPUT"
- },
- "zIndex": 2
- },
- {
- "shape": "dag-edge",
- "connector": {
- "name": "smooth"
- },
- "id": "c3bec4f4-eea9-44ed-b98e-63605d619d50",
- "zIndex": 3,
- "source": {
- "cell": "MySQL",
- "port": "MySQL-out"
- },
- "target": {
- "cell": "Paimon"
- }
- }
- ]
- },
- ],
- pagination: {
- pageSize: 10
- }
- })
-
+ const { tableVariables, getTableData } = useTable()
+ getTableData()
+
return {
t,
...toRefs(tableVariables)
@@ -250,8 +37,8 @@ export default defineComponent({
<n-data-table
columns={this.columns}
data={this.data}
+ remote
pagination={this.pagination}
- bordered={false}
/>
</div>
)
diff --git a/paimon-web-ui-new/src/views/cdc/components/list/use-table.ts b/paimon-web-ui-new/src/views/cdc/components/list/use-table.ts
new file mode 100644
index 0000000..70a3be1
--- /dev/null
+++ b/paimon-web-ui-new/src/views/cdc/components/list/use-table.ts
@@ -0,0 +1,120 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License. */
+
+import { useCDCStore } from '@/store/cdc';
+import type { Router } from 'vue-router';
+import TableAction from '@/components/table-action';
+import { deleteCdcJobDefinition, getCdcJobDefinition, listAllCdcJob } from '@/api/models/cdc';
+import { get } from 'lodash';
+export const useTable = () => {
+ const router: Router = useRouter()
+ const { t } = useLocaleHooks()
+ const tableVariables = reactive({
+ columns: [
+ {
+ title: t('cdc.job_name'),
+ key: 'name',
+ resizable: true
+ },
+ {
+ title: t('cdc.synchronization_type'),
+ key: 'cdcType',
+ resizable: true,
+ render: (row:any)=>{
+ if(row.cdcType == 0){
+ return t('cdc.single_table_synchronization')
+ }else if(row.cdcType ==1){
+ return t('cdc.whole_database_synchronization')
+ }
+ }
+ },
+ {
+ title: t('cdc.job_description'),
+ key: 'description',
+ resizable: true
+ },
+ {
+ title: t('cdc.create_user'),
+ key: 'createUser',
+ resizable: true
+ },
+ {
+ title: t('cdc.create_time'),
+ key: 'createTime',
+ resizable: true
+ },
+ {
+ title: t('cdc.update_time'),
+ key: 'updateTime',
+ resizable: true
+ },
+ {
+ title: t('cdc.operation'),
+ key: 'actions',
+ render: (row: any) =>
+ h(TableAction, {
+ row,
+ onHandleEdit: (row) => {
+ getCdcJobDefinition(row.id).then(res => {
+ const CDCStore = useCDCStore()
+ CDCStore.setModel({
+ cells: JSON.parse(res.data.config).cells,
+ name: res.data.name,
+ editMode: 'edit',
+ id:res.data.id
+ })
+ router.push({ path: '/cdc_ingestion/dag' })
+ })
+ },
+ onHandleDelete:(row)=>{
+ deleteCdcJobDefinition(row.id).then(()=>{
+ getTableData()
+ })
+ }
+ })
+
+ }
+ ],
+ data: [],
+ pagination: {
+ showQuickJumper: true,
+ showSizePicker: true,
+ pageSize: 10,
+ page: 1,
+ count: 100,
+ onUpdatePage: (page: number) => {
+ tableVariables.pagination.page = page
+ getTableData()
+ },
+ onUpdatePageSize: (pageSize: number) => {
+ tableVariables.pagination.pageSize = pageSize
+ tableVariables.pagination.page = 1
+ getTableData()
+ }
+ }
+ })
+ const getTableData = () => {
+ listAllCdcJob(false, tableVariables.pagination.page, tableVariables.pagination.pageSize).then(((res: any) => {
+ tableVariables.data = res.data
+ tableVariables.pagination.count = res.total
+ }))
+ }
+ return {
+ tableVariables,
+ getTableData
+ }
+}
diff --git a/paimon-web-ui-new/src/views/cdc/index.tsx b/paimon-web-ui-new/src/views/cdc/index.tsx
index bd21ba1..5742a08 100644
--- a/paimon-web-ui-new/src/views/cdc/index.tsx
+++ b/paimon-web-ui-new/src/views/cdc/index.tsx
@@ -26,7 +26,6 @@ export default defineComponent({
name: 'CDCPage',
setup() {
const { t } = useLocaleHooks()
-
const showModalRef = ref(false)
const handleOpenModal = () => {
diff --git a/scripts/sql/paimon-mysql.sql b/scripts/sql/paimon-mysql.sql
index a332d1f..db44cab 100644
--- a/scripts/sql/paimon-mysql.sql
+++ b/scripts/sql/paimon-mysql.sql
@@ -126,6 +126,21 @@ CREATE TABLE if not exists `catalog`
options varchar(512) null
) engine = innodb;
+DROP TABLE IF EXISTS `cdc_job_definition`;
+CREATE TABLE if not exists `cdc_job_definition`
+(
+ id int not null comment 'id',
+ `name` varchar(20) not null comment 'name',
+ description varchar(200) null comment 'description',
+ cdc_type int not null comment 'cdc type ',
+ config text null comment 'cdc job config',
+ create_user varchar(20) null comment 'create user',
+ create_time datetime default CURRENT_TIMESTAMP null comment 'create time',
+ update_time datetime default CURRENT_TIMESTAMP null comment 'update time',
+ is_delete tinyint(1) default 0 not null comment 'is delete',
+ constraint cdc_job_definition_pk
+ unique (`name`)
+) engine = innodb;
INSERT INTO `user` ( id, username, password, nickname, mobile
, email, enabled, is_delete)