From 14f9be3e668899412a2ff2c8a95921cebfbaac21 Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Tue, 20 Feb 2024 10:40:52 +0800 Subject: [PATCH] style: unify mapper style array format when using dynamic scripts (") + @Insert({ + ""}) void batchInsert(List connectionEntityList); @Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}") @@ -83,9 +81,11 @@ public List selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan //batch end @Update({ - ""}) + ""}) void batchEndConnectionById(List connectionEntityList); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java index 53a34660..2f5101a3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/connector/ConnectorMapper.java @@ -45,14 +45,14 @@ public interface ConnectorMapper { void insert(ConnectorEntity connectorEntity); @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - @Insert("") + @Insert({ + ""}) void batchInsert(List connectorEntityList); @Update("UPDATE connector SET status = #{status} WHERE id = #{id}") @@ -69,11 +69,11 @@ public interface ConnectorMapper { @Update({ "" }) void batchDeActive(List connectorEntities); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java index f1a91ede..78128619 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java @@ -55,19 +55,19 @@ public interface OprGroupMapper { @Select("select * from `group` where id=#{id} and is_delete=0") GroupEntity selectGroupById(GroupEntity groupEntity); - @Select("") + @Select({ + ""}) List selectGroup(GroupEntity groupEntity); - } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java index 3179effc..aac0a592 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java @@ -59,21 +59,22 @@ public interface OprGroupMemberMapper { @Select("select * from group_member where id=#{id} and is_delete=0") GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); - @Select("") + @Select({ + ""}) List selectMember(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where topic_name=#{topicName}") diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java index 574f9eef..d5d5aab5 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapper.java @@ -55,11 +55,11 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste @Insert({ "" }) void batchInsert(List healthCheckResultEntityList); @@ -68,10 +68,12 @@ List selectByClusterIdAndCreateTimeRange(@Param("cluste void update(HealthCheckResultEntity healthCheckResultEntity); @Update({ - ""}) + ""}) void batchUpdate(List healthCheckResultEntityList); @Select({ diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java index d6c96f72..8f2dbf4e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java @@ -33,21 +33,22 @@ @Mapper public interface OprLogMapper { - @Select("") + @Select({ + ""}) List getLogList(LogEntity logEntity); @Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)" diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java index 8a396be6..42d68d0d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java @@ -35,18 +35,19 @@ @Mapper public interface TopicMapper { - @Select("") + @Select({ + ""}) List getTopicList(TopicEntity topicEntity); @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 776df864..96d4a849 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -21,7 +21,7 @@ CREATE TABLE `group` `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群id', `name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Group名称', `member_count` int unsigned NOT NULL DEFAULT '0' COMMENT '成员数', - `members` text COMMENT 'group的member列表', + `members` varchar(1024) COMMENT 'group的member列表', `type` tinyint NOT NULL COMMENT 'group类型 0:consumer 1:producer', `state` varchar(64) NOT NULL DEFAULT '' COMMENT '状态', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', @@ -62,11 +62,11 @@ CREATE TABLE `operation_log` `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '物理集群ID', `operation_type` varchar(192) NOT NULL DEFAULT '' COMMENT '操作类型,如:启动,停止,重启,添加,删除,修改', `status` int NOT NULL DEFAULT '0' COMMENT '操作状态 0:未知,1:执行中,2:成功,3:失败', - `content` text COMMENT '备注信息', + `content` varchar(1024) COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `operation_user` varchar(192) DEFAULT NULL, - `result` text, + `result` varchar(1024), `target_type` varchar(192) NOT NULL, `is_delete` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), @@ -87,7 +87,7 @@ CREATE TABLE `topic` `storage_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'StorageId', `retention_ms` bigint NOT NULL DEFAULT '-2' COMMENT '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', `type` tinyint NOT NULL DEFAULT '0' COMMENT 'Topic类型,默认0,0:普通,1:EventMesh内部', - `description` text COMMENT '备注信息', + `description` varchar(1024) DEFAULT '' COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间(尽量与Topic实际创建时间一致)', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间(尽量与Topic实际创建时间一致)', `is_delete` int NOT NULL DEFAULT '0', @@ -112,8 +112,8 @@ CREATE TABLE `client` `port` int(16) NOT NULL DEFAULT '-1' COMMENT '客户端端口', `protocol` varchar(192) NOT NULL DEFAULT '' COMMENT '协议类型', `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `config_ids` text NOT NULL DEFAULT ('') COMMENT 'csv config id list, like:1,3,7', - `description` text NOT NULL DEFAULT ('') COMMENT '客户端描述', + `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', @@ -128,16 +128,16 @@ CREATE TABLE `client` DROP TABLE IF EXISTS `connector`; CREATE TABLE `connector` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', - `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', - `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', - `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', - `config_ids` text NOT NULL DEFAULT ('') COMMENT 'csv config id list, like:1,3,7', - `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', + `name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector名称', + `class_name` varchar(512) NOT NULL DEFAULT '' COMMENT 'Connector类', + `type` varchar(32) NOT NULL DEFAULT '' COMMENT 'Connector类型', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + `pod_state` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'k8s pod状态。0: pending;1: running;2: success;3: failed;4: unknown', + `config_ids` varchar(1024) NOT NULL DEFAULT '' COMMENT 'csv config id list, like:1,3,7', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB @@ -156,7 +156,7 @@ CREATE TABLE `connection` `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', `topic` varchar(192) NOT NULL DEFAULT '' COMMENT 'topic name', `group_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'GroupID', - `description` text NOT NULL DEFAULT ('') COMMENT '客户端描述', + `description` varchar(1024) NOT NULL DEFAULT '' COMMENT '客户端描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', @@ -178,7 +178,7 @@ CREATE TABLE `health_check_result` `type_id` bigint(20) unsigned NOT NULL COMMENT '对应检查维度的实例id', `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查状态(0:未通过,1:通过,2:正在检查,3:超时)', - `result_desc` text NOT NULL DEFAULT ('') COMMENT '检查结果描述', + `result_desc` varchar(1024) NOT NULL DEFAULT '' COMMENT '检查结果描述', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java index 49cd6ed1..d91cd229 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/health/HealthCheckResultMapperTest.java @@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java index e4fb11c1..42e58f46 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/mapper/meta/MetaMapperTest.java @@ -17,8 +17,6 @@ package org.apache.eventmesh.dashboard.console.mapper.meta; -import static org.junit.jupiter.api.Assertions.*; - import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.meta.MetaEntity; import org.junit.jupiter.api.Test; @@ -26,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.junit.jupiter.SpringExtension; diff --git a/eventmesh-dashboard-console/src/test/resources/application-test.yml b/eventmesh-dashboard-console/src/test/resources/application-test.yml index e959485b..b70a657c 100644 --- a/eventmesh-dashboard-console/src/test/resources/application-test.yml +++ b/eventmesh-dashboard-console/src/test/resources/application-test.yml @@ -21,7 +21,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + url: jdbc:mysql://localhost:3306/eventmesh_dashboard_test?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: root password: password diff --git a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql index 9006b5e2..db0c0a26 100644 --- a/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql +++ b/eventmesh-dashboard-console/src/test/resources/use-test-schema.sql @@ -15,5 +15,4 @@ * limitations under the License. */ -CREATE DATABASE IF NOT EXISTS `eventmesh_dashboard_test`; -USE `eventmesh_dashboard_test` +USE `eventmesh_dashboard_test`;