From 11d1668b942e93c3cf17e6216fc2ce964452fd1b Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Sun, 21 Jan 2024 15:19:10 +0800 Subject: [PATCH 01/19] refactor: add dependency of console module and move controllers into console module. --- eventmesh-dashboard-common/pom.xml | 28 +++++++- eventmesh-dashboard-console/pom.xml | 55 +++++++++++++++- .../console/EventmeshConsoleApplication.java | 23 +++++++ .../eventmesh/dashboard/console/Main.java | 7 -- .../controller/ConnectionController.java | 2 +- .../controller/MetricsController.java | 2 +- .../controller/SubscriptionController.java | 2 +- .../console}/controller/TopicController.java | 2 +- .../src/main/resources/application-dev.yml | 65 +++++++++++++++++++ .../src/main/resources/application.yml | 22 +++++++ eventmesh-dashboard-core/pom.xml | 38 ++--------- .../src/main/resources/application-dev.yml | 2 +- 12 files changed, 199 insertions(+), 49 deletions(-) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/Main.java rename {eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console}/controller/ConnectionController.java (96%) rename {eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console}/controller/MetricsController.java (95%) rename {eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console}/controller/SubscriptionController.java (98%) rename {eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core => eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console}/controller/TopicController.java (98%) create mode 100644 eventmesh-dashboard-console/src/main/resources/application-dev.yml create mode 100644 eventmesh-dashboard-console/src/main/resources/application.yml diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index 4247216f..c713c15b 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -13,9 +13,33 @@ eventmesh-dashboard-common - 8 - 8 + 1.8 UTF-8 + UTF-8 + 2.7.6 + + + junit + junit + + + org.projectlombok + lombok + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + \ No newline at end of file diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index 2042c89c..4380e6f7 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -13,9 +13,60 @@ eventmesh-dashboard-console - 8 - 8 + 1.8 UTF-8 + UTF-8 + 2.7.6 + + + + org.springdoc + springdoc-openapi-ui + 1.7.0 + + + org.springdoc + springdoc-openapi-javadoc + 1.7.0 + + + + + org.apache.eventmesh.dashboard.core + eventmesh-dashboard-core + 0.0.1-SNAPSHOT + compile + + + + + com.alibaba + druid-spring-boot-starter + 1.2.21 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + com.mysql + mysql-connector-j + runtime + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java new file mode 100644 index 00000000..c47e2d0b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java @@ -0,0 +1,23 @@ +package org.apache.eventmesh.dashboard.console; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +/** + * @author lambert + */ +@Slf4j +@SpringBootApplication +@ComponentScan({"org.apache.eventmesh.dashboard.core"}) +public class EventmeshConsoleApplication { + public static void main(String[] args) { + try{ + SpringApplication.run(EventmeshConsoleApplication.class, args); + log.info("{} 启动成功",EventmeshConsoleApplication.class.getSimpleName()); + }catch (Exception e){ + log.error(e.getMessage(), e); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/Main.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/Main.java deleted file mode 100644 index 7e966a20..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.eventmesh.dashboard.console; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java similarity index 96% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java index 34037d1d..f4dea5cf 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.controller; +package org.apache.eventmesh.dashboard.console.controller; import org.apache.eventmesh.dashboard.core.service.ConnectionService; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java similarity index 95% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java index fbf7dcb9..38f5b1af 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.controller; +package org.apache.eventmesh.dashboard.console.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java similarity index 98% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java index 3b48763a..c124277f 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.controller; +package org.apache.eventmesh.dashboard.console.controller; import org.apache.eventmesh.dashboard.core.dto.Result; import org.apache.eventmesh.dashboard.core.model.SubscriptionInfo; diff --git a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java similarity index 98% rename from eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java index f95ffbbe..a367dfdf 100644 --- a/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.core.controller; +package org.apache.eventmesh.dashboard.console.controller; import org.apache.eventmesh.dashboard.core.dto.CreateTopicRequest; import org.apache.eventmesh.dashboard.core.dto.DeleteTopicRequest; diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml new file mode 100644 index 00000000..2890ce6f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -0,0 +1,65 @@ +# +# 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. +# + +server: + port: 9898 + servlet: + context-path: "/eventmesh" + +spring: + servlet: + multipart: + max-file-size: 500MB + max-request-size: 500MB + application: + name: eventmesh-console + datasource: + name: eventmesh-console + url: jdbc:mysql://${EVENTMESH_CONSOLE_DB_HOST}/eventmesh-dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + username: ${EVENTMESH_CONSOLE_DB_USERNAME} + password: ${EVENTMESH_CONSOLE_DB_PASSWORD} + # using druid data source + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + maxActive: 20 + initialSize: 1 + maxWait: 60000 + minIdle: 1 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + validationQuery: select 'x' + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + poolPreparedStatements: true + maxOpenPreparedStatements: 20 + # encrypt password + filters: config + +mybatis: + checkConfig-location: false + configuration: + useGeneratedKeys: true + mapUnderscoreToCamelCase: true + +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql + + diff --git a/eventmesh-dashboard-console/src/main/resources/application.yml b/eventmesh-dashboard-console/src/main/resources/application.yml new file mode 100644 index 00000000..31966822 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/application.yml @@ -0,0 +1,22 @@ +# +# 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. +# + +spring: + application: + name: eventmesh-dashboard + profiles: + active: dev \ No newline at end of file diff --git a/eventmesh-dashboard-core/pom.xml b/eventmesh-dashboard-core/pom.xml index 98ade695..4b11afd1 100644 --- a/eventmesh-dashboard-core/pom.xml +++ b/eventmesh-dashboard-core/pom.xml @@ -57,11 +57,6 @@ spring-boot-configuration-processor true - - org.projectlombok - lombok - true - org.springframework.boot spring-boot-starter-test @@ -69,6 +64,11 @@ + + org.apache.eventmesh.dashboard.common + eventmesh-dashboard-common + 0.0.1-SNAPSHOT + org.apache.commons commons-lang3 @@ -80,18 +80,6 @@ 2.0.40 - - - org.springdoc - springdoc-openapi-ui - 1.7.0 - - - org.springdoc - springdoc-openapi-javadoc - 1.7.0 - - org.mockito @@ -114,22 +102,6 @@ 4.9.7 - - - com.alibaba - druid-spring-boot-starter - 1.2.21 - - - com.baomidou - mybatis-plus-boot-starter - 3.5.5 - - - com.mysql - mysql-connector-j - runtime - diff --git a/eventmesh-dashboard-core/src/main/resources/application-dev.yml b/eventmesh-dashboard-core/src/main/resources/application-dev.yml index 91377864..f61a3c39 100644 --- a/eventmesh-dashboard-core/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-core/src/main/resources/application-dev.yml @@ -21,7 +21,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/eventmesh-dashboard?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 username: root - password: + password: root initial-size: 1 max-active: 50 From f81c0ddf7a3be6f687d493cef2c5b7677ad71c6c Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Sun, 21 Jan 2024 21:23:20 +0800 Subject: [PATCH 02/19] fix: add logback config, fix application-dev.yml and move `` to root `pom.xml` as pointed out in PR#19. --- eventmesh-dashboard-common/pom.xml | 12 ----- eventmesh-dashboard-console/pom.xml | 44 ++++++++-------- .../console/EventmeshConsoleApplication.java | 29 ++++++++--- .../src/main/resources/application-dev.yml | 44 ++++++---------- .../src/main/resources/application.yml | 18 ++++++- .../src/main/resources/logback.xml | 50 +++++++++++++++++++ eventmesh-dashboard-core/pom.xml | 16 ++++++ .../controller/ConnectionController.java | 2 +- .../core}/controller/MetricsController.java | 2 +- .../controller/SubscriptionController.java | 2 +- .../core}/controller/TopicController.java | 2 +- pom.xml | 18 +++++++ 12 files changed, 165 insertions(+), 74 deletions(-) create mode 100644 eventmesh-dashboard-console/src/main/resources/logback.xml rename {eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core}/controller/ConnectionController.java (96%) rename {eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core}/controller/MetricsController.java (95%) rename {eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core}/controller/SubscriptionController.java (98%) rename {eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console => eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core}/controller/TopicController.java (98%) diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index c713c15b..f79bd00c 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -30,16 +30,4 @@ - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - \ No newline at end of file diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index 4380e6f7..fa06c450 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.eventmesh.dashboard @@ -16,10 +16,20 @@ 1.8 UTF-8 UTF-8 - 2.7.6 + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + org.springdoc @@ -32,12 +42,16 @@ 1.7.0 - + + + org.apache.eventmesh.dashboard.common + eventmesh-dashboard-common + 0.0.1-SNAPSHOT + - org.apache.eventmesh.dashboard.core - eventmesh-dashboard-core + org.apache.eventmesh.dashboard.service + eventmesh-dashboard-service 0.0.1-SNAPSHOT - compile @@ -47,9 +61,8 @@ 1.2.21 - com.baomidou - mybatis-plus-boot-starter - 3.5.5 + org.mybatis.spring.boot + mybatis-spring-boot-starter com.mysql @@ -58,15 +71,4 @@ - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java index c47e2d0b..1e4d6dba 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java @@ -1,3 +1,20 @@ +/* + * 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.eventmesh.dashboard.console; import lombok.extern.slf4j.Slf4j; @@ -5,18 +22,16 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; -/** - * @author lambert - */ @Slf4j @SpringBootApplication -@ComponentScan({"org.apache.eventmesh.dashboard.core"}) +@ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) public class EventmeshConsoleApplication { + public static void main(String[] args) { - try{ + try { SpringApplication.run(EventmeshConsoleApplication.class, args); - log.info("{} 启动成功",EventmeshConsoleApplication.class.getSimpleName()); - }catch (Exception e){ + log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); + } catch (Exception e) { log.error(e.getMessage(), e); } } diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 2890ce6f..bfe02806 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -29,37 +29,23 @@ spring: name: eventmesh-console datasource: name: eventmesh-console - url: jdbc:mysql://${EVENTMESH_CONSOLE_DB_HOST}/eventmesh-dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true - username: ${EVENTMESH_CONSOLE_DB_USERNAME} - password: ${EVENTMESH_CONSOLE_DB_PASSWORD} - # using druid data source type: com.alibaba.druid.pool.DruidDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - maxActive: 20 - initialSize: 1 - maxWait: 60000 - minIdle: 1 - timeBetweenEvictionRunsMillis: 60000 - minEvictableIdleTimeMillis: 300000 - validationQuery: select 'x' - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - poolPreparedStatements: true - maxOpenPreparedStatements: 20 - # encrypt password - filters: config + druid: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/eventmesh-dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true + username: root + password: root + + initial-size: 1 + max-active: 50 + min-idle: 5 + max-wait: 6000 + validation-query: select 'x' + validation-query-timeout: 15 + test-on-borrow: false + test-while-idle: true + min-evictable-idle-time-millis: 300000 -mybatis: - checkConfig-location: false - configuration: - useGeneratedKeys: true - mapUnderscoreToCamelCase: true -pagehelper: - helperDialect: mysql - reasonable: true - supportMethodsArguments: true - params: count=countSql diff --git a/eventmesh-dashboard-console/src/main/resources/application.yml b/eventmesh-dashboard-console/src/main/resources/application.yml index 31966822..f39890e9 100644 --- a/eventmesh-dashboard-console/src/main/resources/application.yml +++ b/eventmesh-dashboard-console/src/main/resources/application.yml @@ -19,4 +19,20 @@ spring: application: name: eventmesh-dashboard profiles: - active: dev \ No newline at end of file + active: dev + +logging: + config: classpath:logback.xml + +mybatis: + checkConfig-location: false + configuration: + useGeneratedKeys: true + mapUnderscoreToCamelCase: true + + +pagehelper: + helperDialect: mysql + reasonable: true + supportMethodsArguments: true + params: count=countSql \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/resources/logback.xml b/eventmesh-dashboard-console/src/main/resources/logback.xml new file mode 100644 index 00000000..c9925d33 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/logback.xml @@ -0,0 +1,50 @@ + + + + + + + [%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n + + + + + ${user.home}/logs/eventmesh-dashboard.log + true + + ${user.home}/logs/eventmesh-dashboard-%d{yyyy-MM-dd}.%i.log + + + 104857600 + + 10 + + + [%d{yyyy-MM-dd HH:mm:ss.SSS}] %p %t - %m%n + UTF-8 + + + + + + + + + \ No newline at end of file diff --git a/eventmesh-dashboard-core/pom.xml b/eventmesh-dashboard-core/pom.xml index 4b11afd1..651cad83 100644 --- a/eventmesh-dashboard-core/pom.xml +++ b/eventmesh-dashboard-core/pom.xml @@ -102,6 +102,22 @@ 4.9.7 + + + com.alibaba + druid-spring-boot-starter + 1.2.21 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + com.mysql + mysql-connector-j + runtime + diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java similarity index 96% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java index f4dea5cf..34037d1d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/ConnectionController.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/ConnectionController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.core.controller; import org.apache.eventmesh.dashboard.core.service.ConnectionService; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java similarity index 95% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java index 38f5b1af..fbf7dcb9 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/MetricsController.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/MetricsController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.core.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java similarity index 98% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java index c124277f..3b48763a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/SubscriptionController.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/SubscriptionController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.core.controller; import org.apache.eventmesh.dashboard.core.dto.Result; import org.apache.eventmesh.dashboard.core.model.SubscriptionInfo; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java similarity index 98% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java rename to eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java index a367dfdf..f95ffbbe 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/controller/TopicController.java +++ b/eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/controller/TopicController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.controller; +package org.apache.eventmesh.dashboard.core.controller; import org.apache.eventmesh.dashboard.core.dto.CreateTopicRequest; import org.apache.eventmesh.dashboard.core.dto.DeleteTopicRequest; diff --git a/pom.xml b/pom.xml index 3abf4205..ed8fd4fb 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,8 @@ 8 8 UTF-8 + 2.7.6 + 2.3.2 @@ -87,4 +89,20 @@ eventmesh-dashboard-service eventmesh-dashboard-common + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${mybatis-spring-boot.version} + + + \ No newline at end of file From d9cf4197f46aae33e5b04f09369c207af2cced25 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Sun, 28 Jan 2024 16:22:59 +0800 Subject: [PATCH 03/19] FirstCommit --- eventmesh-dashboard-console/pom.xml | 8 ++ .../dashboard/console/annotation/EmLog.java | 33 ++++++ .../dashboard/console/entity/GroupEntity.java | 51 +++++++++ .../console/entity/GroupMemberEntity.java | 47 ++++++++ .../dashboard/console/entity/LogEntity.java | 48 +++++++++ .../dashboard/console/entity/TopicEntity.java | 50 +++++++++ .../dashboard/console/log/OprLog.java | 100 ++++++++++++++++++ .../log/service/Impl/LogServiceImpl.java | 52 +++++++++ .../console/log/service/LogService.java | 38 +++++++ .../dashboard/console/mapper/OprGroupDao.java | 55 ++++++++++ .../console/mapper/OprGroupMemberDao.java | 65 ++++++++++++ .../dashboard/console/mapper/OprLogDao.java | 46 ++++++++ .../dashboard/console/mapper/TopicDao.java | 56 ++++++++++ .../console/service/GroupMemberService.java | 44 ++++++++ .../console/service/GroupService.java | 44 ++++++++ .../service/Impl/GroupMemberServiceImp.java | 79 ++++++++++++++ .../service/Impl/GroupServiceImpl.java | 98 +++++++++++++++++ .../service/Impl/TopicServiceImpl.java | 83 +++++++++++++++ .../console/service/TopicService.java | 41 +++++++ .../src/main/resources/application-dev.yml | 6 +- .../main/resources/eventmesh-dashboard.sql | 90 ++++++++++++++++ eventmesh-dashboard-service/pom.xml | 4 + 22 files changed, 1137 insertions(+), 1 deletion(-) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java create mode 100644 eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index fa06c450..242c2550 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -69,6 +69,14 @@ mysql-connector-j runtime + + + org.springframework + spring-aspects + 5.1.2.RELEASE + + + \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java new file mode 100644 index 00000000..efae3a5b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java @@ -0,0 +1,33 @@ +/* + * 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.eventmesh.dashboard.console.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface EmLog { + + String OprType() default ""; + + String OprTarget() default ""; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java new file mode 100644 index 00000000..a394a397 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GroupEntity { + private Long id; + + private Long clusterId; + + private String name; + + private Integer memberCount; + + + private String members; + + private Integer type; + + private String state; + + private Timestamp createTime; + + private Timestamp updateTime; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java new file mode 100644 index 00000000..9433d6d0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java @@ -0,0 +1,47 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroupMemberEntity { + private Long id; + + private Long clusterId; + + private String topicName; + + private String groupName; + + private String eventMeshUser; + + private String state; + + private Timestamp createTime; + + private Timestamp updateTime; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java new file mode 100644 index 00000000..7af7a276 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java @@ -0,0 +1,48 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LogEntity { + + private Long id; + + private Long clusterId; + + private String operationType; + + private String operationTarget; + + private Integer status; + + private String description; + + private Timestamp createTime; + + private Timestamp endTime; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java new file mode 100644 index 00000000..94f1de6c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java @@ -0,0 +1,50 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TopicEntity { + private Long id; + + private Long clusterId; + + private String topicName; + + private String runtimeId; + + private String storageId; + + private Long retentionMs; + + private Integer type; + + private String description; + + private Timestamp createTime; + + private Timestamp updateTime; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java new file mode 100644 index 00000000..cad27277 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -0,0 +1,100 @@ +/* + * 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.eventmesh.dashboard.console.log; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.log.service.LogService; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.sql.Timestamp; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.Ordered; +import org.springframework.stereotype.Service; +import org.springframework.util.ClassUtils; + +@Aspect +@Service +public class OprLog implements Ordered { + + private int order = LOWEST_PRECEDENCE - 1000; // Specify the order of execution + + @Autowired + private LogService logService; + + @Pointcut("within(org.apache.eventmesh.dashboard.console.service..*)") + public void pointCut() { + } + + @Around("pointCut()") + public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { + LogEntity logEntity = new LogEntity(); + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + Method mostSpecificMethod = ClassUtils.getMostSpecificMethod(method, joinPoint.getTarget().getClass()); + EmLog declaredAnnotation = mostSpecificMethod.getAnnotation(EmLog.class); + //Get the Emlog annotation on the method + if (declaredAnnotation != null) { + //It is a method of operation + logEntity.setOperationType(declaredAnnotation.OprType()); + logEntity.setOperationType(declaredAnnotation.OprTarget()); + Object[] args = joinPoint.getArgs(); + Object model = args[0]; + //Obtaining the Input Parameter of the Operation Method (Specified as the First) + Field clusterPhyId = model.getClass().getDeclaredField("clusterId"); + clusterPhyId.setAccessible(true); + Long opClusterPhyId = (Long) clusterPhyId.get(model); + String opDescription = model.toString(); + logEntity.setClusterId(opClusterPhyId); + logEntity.setDescription(opDescription); + //The clusterId is obtained from the parameter object, and the operation is described as the object itself + logEntity.setStatus(1); + logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); + logService.addLog(logEntity); + Object proceed = joinPoint.proceed(); + if (proceed == null) { + //An exception occurred with the target method + logEntity.setStatus(3); + logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + Integer integer1 = logService.updateLog(logEntity); + return proceed; + } else { + //The target approach is successful + logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + logEntity.setStatus(2); + Integer integer1 = logService.updateLog(logEntity); + return proceed; + } + } else { + //It is not part of the operation method + return joinPoint.proceed(); + } + } + + @Override + public int getOrder() { + return order; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java new file mode 100644 index 00000000..d19b0cab --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.eventmesh.dashboard.console.log.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.log.service.LogService; +import org.apache.eventmesh.dashboard.console.mapper.OprLogDao; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class LogServiceImpl implements LogService { + + @Autowired + OprLogDao oprLogDao; + + @Override + public List getLogListByCluster() { + + return oprLogDao.getLogList(); + } + + @Override + public Long addLog(LogEntity logEntity) { + + return oprLogDao.addLog(logEntity); + } + + @Override + public Integer updateLog(LogEntity logEntity) { + + return oprLogDao.updateLog(logEntity); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java new file mode 100644 index 00000000..eac03df5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.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.eventmesh.dashboard.console.log.service; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; + +import java.util.List; + +/** + * + * operation service + * + */ + +public interface LogService { + + List getLogListByCluster(); + + Long addLog(LogEntity logEntity); + + Integer updateLog(LogEntity logEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java new file mode 100644 index 00000000..abca67d3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java @@ -0,0 +1,55 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** +operate Group mapper + **/ +@Mapper +public interface OprGroupDao { + @Select("select * from `group` where cluster_id=#{clusterId}") + List getGroupList(GroupEntity groupEntity); + + @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state, create_time, update_time)" + + "VALUE (#{clusterId},#{name},#{memberCount},#{Members},#{type},#{state},#{createTime},#{updateTime})") + Integer addGroup(GroupEntity groupEntity); + + @Update("update `group`set cluster_id=#{clusterId},name=#{name},member_count=#{memberCount}," + + "members=#{Members},type=#{type},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateGroup(GroupEntity groupEntity); + + @Delete("delete from `group` where id=#{id}") + Integer deleteGroup(Long id); + + @Select("select * from `group` where cluster_id=#{clusterId} and name=#{name}") + GroupEntity selectGroupByUnique(GroupEntity groupEntity); + + @Select("select * from `group` where id=#{id}") + GroupEntity selectGroupById(GroupEntity groupEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java new file mode 100644 index 00000000..7c965919 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java @@ -0,0 +1,65 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + + +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate GroupMember mapper + **/ + +@Mapper +public interface OprGroupMemberDao { + @Select("select * from group_member where cluster_id=#{clusterId}") + List getGroupList(GroupMemberEntity groupMemberEntity); + + @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user, state, create_time, update_time)" + + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state},#{createTime},#{updateTime})") + Integer addGroupMember(GroupMemberEntity groupMemberEntity); + + @Update("update group_member set cluster_id=#{clusterId},topic_name=#{topicName},group_name=#{groupName}" + + ",eventmesh_user=#{eventMeshUser},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + + @Delete("delete from group_member where id=#{id}") + Integer deleteGroupMember(Long id); + + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName}") + GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where id=#{id}") + GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName}") + List selectAllMemberByUnique(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where topic_name=#{topicName}") + List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + + @Update("update group_member set state=#{state} where topic_name=#{topicName}") + Integer updateMemberByTopic(GroupMemberEntity groupMemberEntity); +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java new file mode 100644 index 00000000..2c769772 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java @@ -0,0 +1,46 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate operationLog mapper + **/ +@Mapper +public interface OprLogDao { + + @Select("select * from operation_log where cluster_id") + List getLogList(); + + @Insert("insert into operation_log ( cluster_id, operation_type, status, description, create_time) " + + "VALUE (#{clusterId},#{operationType},#{status},#{description},#{createTime})") + @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) + Long addLog(LogEntity logEntity); + + @Update("update operation_log set status=#{status},end_time=#{endTime} where id=#{id}") + Integer updateLog(LogEntity logEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java new file mode 100644 index 00000000..c5c71036 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java @@ -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. + */ + +package org.apache.eventmesh.dashboard.console.mapper; + + +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate Topic mapper + **/ +@Mapper +public interface TopicDao { + @Select("select * from `topic` where cluster_id=#{clusterId}") + List getTopicList(TopicEntity topicEntity); + + @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description, create_time, update_time) " + + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description},#{createTime},#{updateTime})") + Integer addTopic(TopicEntity topicEntity); + + @Update("update topic set cluster_id=#{clusterId},topic_name=#{topicName},runtime_id=#{runtimeId},storage_id=#{storageId}," + + "retention_ms=#{retentionMs},type=#{type},description=#{description},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateTopic(TopicEntity topicEntity); + + @Delete("delete from `topic` where id=#{id}") + Integer deleteTopic(Long id); + + @Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}") + TopicEntity selectTopicByUnique(TopicEntity topicEntity); + + @Select("select * from topic where id=#{id}") + TopicEntity selectTopicById(TopicEntity topicEntity); + +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java new file mode 100644 index 00000000..d307d52f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + +import java.util.List; + +/** + * Service About GroupMember + */ +public interface GroupMemberService { + + List getGroupMember(GroupMemberEntity groupMemberEntity); + + Integer addGroupMember(GroupMemberEntity groupMemberEntity); + + Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + + Integer deleteGroupMember(Long id); + + GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); + + List selectGroupMemberByGroup(GroupEntity groupEntity); + + List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java new file mode 100644 index 00000000..647dc5d3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + + +import java.util.List; + +/** + * operate Group Service + */ + +public interface GroupService { + List getGroupList(GroupEntity groupEntity); + + Integer addGroup(GroupEntity groupEntity); + + Integer updateGroup(GroupEntity groupEntity); + + Integer deleteGroup(Long id); + + GroupEntity selectGroup(GroupEntity groupEntity); + + Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity); + + Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java new file mode 100644 index 00000000..4358c350 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java @@ -0,0 +1,79 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; +import org.apache.eventmesh.dashboard.console.service.GroupMemberService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GroupMemberServiceImp implements GroupMemberService { + + @Autowired + OprGroupMemberDao oprGroupMemberDao; + + @Override + @EmLog(OprType = "View", OprTarget = "GroupMember") + public List getGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.getGroupList(groupMemberEntity); + } + + @Override + @EmLog(OprType = "add", OprTarget = "GroupMember") + public Integer addGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.addGroupMember(groupMemberEntity); + } + + @Override + public Integer updateGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.updateGroupMember(groupMemberEntity); + } + + @Override + public Integer deleteGroupMember(Long id) { + return oprGroupMemberDao.deleteGroupMember(id); + } + + @Override + public GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.selectGroupMemberById(groupMemberEntity); + } + + @Override + public List selectGroupMemberByGroup(GroupEntity groupEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setGroupName(groupEntity.getName()); + groupMemberEntity.setClusterId(groupEntity.getClusterId()); + //Obtain a member who meets the conditions of a group + return oprGroupMemberDao.selectAllMemberByUnique(groupMemberEntity); + } + + @Override + public List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) { + List groupMemberEntities = oprGroupMemberDao.selectAllMemberByTopic(groupMemberEntity); + return groupMemberEntities; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java new file mode 100644 index 00000000..69a2a18b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java @@ -0,0 +1,98 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupDao; +import org.apache.eventmesh.dashboard.console.service.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.GroupService; + +import java.sql.Timestamp; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GroupServiceImpl implements GroupService { + + @Autowired + OprGroupDao oprGroupDao; + + @Autowired + GroupMemberService groupMemberService; + + @Override + public List getGroupList(GroupEntity groupEntity) { + return oprGroupDao.getGroupList(groupEntity); + + } + + @Override + public Integer addGroup(GroupEntity groupEntity) { + return oprGroupDao.addGroup(groupEntity); + } + + @Override + public Integer updateGroup(GroupEntity groupEntity) { + return oprGroupDao.updateGroup(groupEntity); + } + + @Override + public Integer deleteGroup(Long id) { + return oprGroupDao.deleteGroup(id); + } + + @Override + public GroupEntity selectGroup(GroupEntity groupEntity) { + return oprGroupDao.selectGroupById(groupEntity); + } + + @Override + public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) { + groupMemberService.addGroupMember(groupMemberEntity); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(groupMemberEntity.getGroupName()); + groupEntity.setClusterId(groupMemberEntity.getClusterId()); + GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + //^Obtain the group to which the member belongs + groupEntity1.setMembers(groupMemberEntity.getId() + "" + "," + groupEntity1.getMembers()); + //Concatenate the members of the group + groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); + groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + return oprGroupDao.updateGroup(groupEntity1); + //Modify the group member information + } + + @Override + public Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity) { + groupMemberService.deleteGroupMember(groupMemberEntity.getId()); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(groupMemberEntity.getGroupName()); + groupEntity.setClusterId(groupMemberEntity.getClusterId()); + GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + //^Obtain the group to which the member belongs + groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(groupMemberEntity.getId() + "" + ",", "")); + groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); + groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + return oprGroupDao.updateGroup(groupEntity1); + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java new file mode 100644 index 00000000..6b922f1c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java @@ -0,0 +1,83 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; +import org.apache.eventmesh.dashboard.console.mapper.TopicDao; +import org.apache.eventmesh.dashboard.console.service.TopicService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TopicServiceImpl implements TopicService { + + @Autowired + TopicDao topicDao; + + @Autowired + OprGroupMemberDao oprGroupMemberDao; + + + @Override + public List getTopicList(TopicEntity topicEntity) { + return topicDao.getTopicList(topicEntity); + } + + @Override + public Integer addTopic_plus(TopicEntity topicEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicEntity.getTopicName()); + groupMemberEntity.setState("active"); + oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); + return topicDao.addTopic(topicEntity); + } + + @Override + public Integer updateTopic(TopicEntity topicEntity) { + return topicDao.updateTopic(topicEntity); + } + + @Override + public Integer deleteTopic(Long id) { + return topicDao.deleteTopic(id); + } + + @Override + public TopicEntity selectTopicById(TopicEntity topicEntity) { + return topicDao.selectTopicById(topicEntity); + } + + @Override + public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { + return topicDao.selectTopicByUnique(topicEntity); + } + + @Override + public Integer deleteTopic_plus(TopicEntity topicEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicEntity.getTopicName()); + groupMemberEntity.setState("empty"); + oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); + return topicDao.deleteTopic(topicEntity.getId()); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java new file mode 100644 index 00000000..b50b08d9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java @@ -0,0 +1,41 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; + +import java.util.List; + +/** + * Service about Topic + */ +public interface TopicService { + List getTopicList(TopicEntity topicEntity); + + Integer addTopic_plus(TopicEntity topicEntity); + + Integer updateTopic(TopicEntity topicEntity); + + Integer deleteTopic(Long id); + + TopicEntity selectTopicById(TopicEntity topicEntity); + + TopicEntity selectTopicByUnique(TopicEntity topicEntity); + + Integer deleteTopic_plus(TopicEntity topicEntity); +} diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index bfe02806..377c1334 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -34,7 +34,7 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/eventmesh-dashboard?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true username: root - password: root + password: 123456 initial-size: 1 max-active: 50 @@ -46,6 +46,10 @@ spring: test-while-idle: true min-evictable-idle-time-millis: 300000 +mybatis: + type-aliases-package: org.apache.eventmesh.dashboard.console.entity + + diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql new file mode 100644 index 00000000..a10f6915 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -0,0 +1,90 @@ +create table operation_log +( + id bigint unsigned auto_increment comment 'id' + primary key, + cluster_id bigint default -1 not null comment '物理集群ID', + operation_type varchar(192) default '' not null comment '操作类型,如:启动,停止,重启,添加,删除,修改', + status int default 0 not null comment '操作状态 0:未知,1:执行中,2:成功,3:失败', + description text null comment '备注信息', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', + end_time timestamp default CURRENT_TIMESTAMP null comment '结束时间' +) + comment '操作记录信息表'; + +create index idx_cluster_phy_id + on operation_log (cluster_id); + +create index idx_status + on operation_log (status); + + + + +create table topic +( + id bigint unsigned auto_increment comment 'id' + primary key, + cluster_id bigint default -1 not null comment '集群ID', + topic_name varchar(192) collate utf8_bin default '' not null comment 'Topic名称', + runtime_id varchar(2048) default '' not null comment 'RuntimeId', + storage_id varchar(2048) default '' not null comment 'StorageId', + retention_ms bigint default -2 not null comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', + type tinyint default 0 not null comment 'Topic类型,默认0,0:普通,1:EventMesh内部', + description text null comment '备注信息', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间(尽量与Topic实际创建时间一致)', + update_time timestamp default CURRENT_TIMESTAMP not null comment '修改时间(尽量与Topic实际创建时间一致)', + constraint uniq_cluster_phy_id_topic_name + unique (cluster_id, topic_name) +) + comment 'Topic信息表'; + +create index cluster_id + on topic (cluster_id, topic_name); + + + +create table topic +( + id bigint unsigned auto_increment comment 'id' + primary key, + cluster_id bigint default -1 not null comment '集群ID', + topic_name varchar(192) collate utf8_bin default '' not null comment 'Topic名称', + runtime_id varchar(2048) default '' not null comment 'RuntimeId', + storage_id varchar(2048) default '' not null comment 'StorageId', + retention_ms bigint default -2 not null comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', + type tinyint default 0 not null comment 'Topic类型,默认0,0:普通,1:EventMesh内部', + description text null comment '备注信息', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间(尽量与Topic实际创建时间一致)', + update_time timestamp default CURRENT_TIMESTAMP not null comment '修改时间(尽量与Topic实际创建时间一致)', + constraint uniq_cluster_phy_id_topic_name + unique (cluster_id, topic_name) +) + comment 'Topic信息表'; + +create index cluster_id + on topic (cluster_id, topic_name); + + + + + +create table `group` +( + id bigint unsigned auto_increment comment 'id' + primary key, + cluster_id bigint default -1 not null comment '集群id', + name varchar(192) collate utf8_bin default '' not null comment 'Group名称', + member_count int unsigned default '0' not null comment '成员数', + members text null comment 'group的member列表', + type tinyint not null comment 'group类型 0:consumer 1:producer', + state varchar(64) default '' not null comment '状态', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', + update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', + constraint uniq_cluster_phy_id_name + unique (cluster_id, name) +) + comment 'Group信息表'; + +create index cluster_id + on `group` (cluster_id, name); + diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index f445adaf..4c468287 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -18,4 +18,8 @@ UTF-8 + + + + \ No newline at end of file From df369e7a3e94658f364225433198c0f2b429a5db Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Thu, 1 Feb 2024 18:24:42 +0800 Subject: [PATCH 04/19] remerge --- .../console/EventmeshConsoleApplication.java | 38 +++++++ .../dashboard/console/annotation/EmLog.java | 33 ++++++ .../dashboard/console/entity/GroupEntity.java | 51 +++++++++ .../console/entity/GroupMemberEntity.java | 47 ++++++++ .../dashboard/console/entity/LogEntity.java | 48 +++++++++ .../dashboard/console/entity/TopicEntity.java | 50 +++++++++ .../dashboard/console/log/OprLog.java | 100 ++++++++++++++++++ .../log/service/Impl/LogServiceImpl.java | 52 +++++++++ .../console/log/service/LogService.java | 38 +++++++ .../dashboard/console/mapper/OprGroupDao.java | 55 ++++++++++ .../console/mapper/OprGroupMemberDao.java | 65 ++++++++++++ .../dashboard/console/mapper/OprLogDao.java | 46 ++++++++ .../dashboard/console/mapper/TopicDao.java | 56 ++++++++++ .../console/service/GroupMemberService.java | 44 ++++++++ .../console/service/GroupService.java | 44 ++++++++ .../service/Impl/GroupMemberServiceImp.java | 79 ++++++++++++++ .../service/Impl/GroupServiceImpl.java | 98 +++++++++++++++++ .../service/Impl/TopicServiceImpl.java | 83 +++++++++++++++ .../console/service/TopicService.java | 41 +++++++ .../testLinkedServiceOfTheThreeTable.java | 54 ++++++++++ .../console/linkage/log/TestOprLog.java | 29 +++++ .../console/unit/group/TestGroupDao.java | 97 +++++++++++++++++ .../unit/groupmember/testGroupMemberDao.java | 99 +++++++++++++++++ .../console/unit/topic/testTopicDao.java | 57 ++++++++++ 24 files changed, 1404 insertions(+) create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java create mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java new file mode 100644 index 00000000..1e4d6dba --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.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.eventmesh.dashboard.console; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@Slf4j +@SpringBootApplication +@ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) +public class EventmeshConsoleApplication { + + public static void main(String[] args) { + try { + SpringApplication.run(EventmeshConsoleApplication.class, args); + log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java new file mode 100644 index 00000000..efae3a5b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/annotation/EmLog.java @@ -0,0 +1,33 @@ +/* + * 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.eventmesh.dashboard.console.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface EmLog { + + String OprType() default ""; + + String OprTarget() default ""; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java new file mode 100644 index 00000000..a394a397 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +public class GroupEntity { + private Long id; + + private Long clusterId; + + private String name; + + private Integer memberCount; + + + private String members; + + private Integer type; + + private String state; + + private Timestamp createTime; + + private Timestamp updateTime; + + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java new file mode 100644 index 00000000..9433d6d0 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java @@ -0,0 +1,47 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class GroupMemberEntity { + private Long id; + + private Long clusterId; + + private String topicName; + + private String groupName; + + private String eventMeshUser; + + private String state; + + private Timestamp createTime; + + private Timestamp updateTime; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java new file mode 100644 index 00000000..7af7a276 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java @@ -0,0 +1,48 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LogEntity { + + private Long id; + + private Long clusterId; + + private String operationType; + + private String operationTarget; + + private Integer status; + + private String description; + + private Timestamp createTime; + + private Timestamp endTime; + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java new file mode 100644 index 00000000..94f1de6c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java @@ -0,0 +1,50 @@ +/* + * 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.eventmesh.dashboard.console.entity; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TopicEntity { + private Long id; + + private Long clusterId; + + private String topicName; + + private String runtimeId; + + private String storageId; + + private Long retentionMs; + + private Integer type; + + private String description; + + private Timestamp createTime; + + private Timestamp updateTime; + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java new file mode 100644 index 00000000..cad27277 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -0,0 +1,100 @@ +/* + * 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.eventmesh.dashboard.console.log; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.log.service.LogService; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.sql.Timestamp; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.Ordered; +import org.springframework.stereotype.Service; +import org.springframework.util.ClassUtils; + +@Aspect +@Service +public class OprLog implements Ordered { + + private int order = LOWEST_PRECEDENCE - 1000; // Specify the order of execution + + @Autowired + private LogService logService; + + @Pointcut("within(org.apache.eventmesh.dashboard.console.service..*)") + public void pointCut() { + } + + @Around("pointCut()") + public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { + LogEntity logEntity = new LogEntity(); + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + Method mostSpecificMethod = ClassUtils.getMostSpecificMethod(method, joinPoint.getTarget().getClass()); + EmLog declaredAnnotation = mostSpecificMethod.getAnnotation(EmLog.class); + //Get the Emlog annotation on the method + if (declaredAnnotation != null) { + //It is a method of operation + logEntity.setOperationType(declaredAnnotation.OprType()); + logEntity.setOperationType(declaredAnnotation.OprTarget()); + Object[] args = joinPoint.getArgs(); + Object model = args[0]; + //Obtaining the Input Parameter of the Operation Method (Specified as the First) + Field clusterPhyId = model.getClass().getDeclaredField("clusterId"); + clusterPhyId.setAccessible(true); + Long opClusterPhyId = (Long) clusterPhyId.get(model); + String opDescription = model.toString(); + logEntity.setClusterId(opClusterPhyId); + logEntity.setDescription(opDescription); + //The clusterId is obtained from the parameter object, and the operation is described as the object itself + logEntity.setStatus(1); + logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); + logService.addLog(logEntity); + Object proceed = joinPoint.proceed(); + if (proceed == null) { + //An exception occurred with the target method + logEntity.setStatus(3); + logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + Integer integer1 = logService.updateLog(logEntity); + return proceed; + } else { + //The target approach is successful + logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + logEntity.setStatus(2); + Integer integer1 = logService.updateLog(logEntity); + return proceed; + } + } else { + //It is not part of the operation method + return joinPoint.proceed(); + } + } + + @Override + public int getOrder() { + return order; + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java new file mode 100644 index 00000000..d19b0cab --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.eventmesh.dashboard.console.log.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.log.service.LogService; +import org.apache.eventmesh.dashboard.console.mapper.OprLogDao; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class LogServiceImpl implements LogService { + + @Autowired + OprLogDao oprLogDao; + + @Override + public List getLogListByCluster() { + + return oprLogDao.getLogList(); + } + + @Override + public Long addLog(LogEntity logEntity) { + + return oprLogDao.addLog(logEntity); + } + + @Override + public Integer updateLog(LogEntity logEntity) { + + return oprLogDao.updateLog(logEntity); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java new file mode 100644 index 00000000..eac03df5 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.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.eventmesh.dashboard.console.log.service; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; + +import java.util.List; + +/** + * + * operation service + * + */ + +public interface LogService { + + List getLogListByCluster(); + + Long addLog(LogEntity logEntity); + + Integer updateLog(LogEntity logEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java new file mode 100644 index 00000000..abca67d3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java @@ -0,0 +1,55 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** +operate Group mapper + **/ +@Mapper +public interface OprGroupDao { + @Select("select * from `group` where cluster_id=#{clusterId}") + List getGroupList(GroupEntity groupEntity); + + @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state, create_time, update_time)" + + "VALUE (#{clusterId},#{name},#{memberCount},#{Members},#{type},#{state},#{createTime},#{updateTime})") + Integer addGroup(GroupEntity groupEntity); + + @Update("update `group`set cluster_id=#{clusterId},name=#{name},member_count=#{memberCount}," + + "members=#{Members},type=#{type},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateGroup(GroupEntity groupEntity); + + @Delete("delete from `group` where id=#{id}") + Integer deleteGroup(Long id); + + @Select("select * from `group` where cluster_id=#{clusterId} and name=#{name}") + GroupEntity selectGroupByUnique(GroupEntity groupEntity); + + @Select("select * from `group` where id=#{id}") + GroupEntity selectGroupById(GroupEntity groupEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java new file mode 100644 index 00000000..7c965919 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java @@ -0,0 +1,65 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + + +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate GroupMember mapper + **/ + +@Mapper +public interface OprGroupMemberDao { + @Select("select * from group_member where cluster_id=#{clusterId}") + List getGroupList(GroupMemberEntity groupMemberEntity); + + @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user, state, create_time, update_time)" + + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state},#{createTime},#{updateTime})") + Integer addGroupMember(GroupMemberEntity groupMemberEntity); + + @Update("update group_member set cluster_id=#{clusterId},topic_name=#{topicName},group_name=#{groupName}" + + ",eventmesh_user=#{eventMeshUser},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + + @Delete("delete from group_member where id=#{id}") + Integer deleteGroupMember(Long id); + + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName}") + GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where id=#{id}") + GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName}") + List selectAllMemberByUnique(GroupMemberEntity groupMemberEntity); + + @Select("select * from group_member where topic_name=#{topicName}") + List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + + @Update("update group_member set state=#{state} where topic_name=#{topicName}") + Integer updateMemberByTopic(GroupMemberEntity groupMemberEntity); +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java new file mode 100644 index 00000000..2c769772 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java @@ -0,0 +1,46 @@ +/* + * 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.eventmesh.dashboard.console.mapper; + +import org.apache.eventmesh.dashboard.console.entity.LogEntity; + +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectKey; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate operationLog mapper + **/ +@Mapper +public interface OprLogDao { + + @Select("select * from operation_log where cluster_id") + List getLogList(); + + @Insert("insert into operation_log ( cluster_id, operation_type, status, description, create_time) " + + "VALUE (#{clusterId},#{operationType},#{status},#{description},#{createTime})") + @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) + Long addLog(LogEntity logEntity); + + @Update("update operation_log set status=#{status},end_time=#{endTime} where id=#{id}") + Integer updateLog(LogEntity logEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java new file mode 100644 index 00000000..c5c71036 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java @@ -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. + */ + +package org.apache.eventmesh.dashboard.console.mapper; + + +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.List; + +/** + operate Topic mapper + **/ +@Mapper +public interface TopicDao { + @Select("select * from `topic` where cluster_id=#{clusterId}") + List getTopicList(TopicEntity topicEntity); + + @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description, create_time, update_time) " + + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description},#{createTime},#{updateTime})") + Integer addTopic(TopicEntity topicEntity); + + @Update("update topic set cluster_id=#{clusterId},topic_name=#{topicName},runtime_id=#{runtimeId},storage_id=#{storageId}," + + "retention_ms=#{retentionMs},type=#{type},description=#{description},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + Integer updateTopic(TopicEntity topicEntity); + + @Delete("delete from `topic` where id=#{id}") + Integer deleteTopic(Long id); + + @Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}") + TopicEntity selectTopicByUnique(TopicEntity topicEntity); + + @Select("select * from topic where id=#{id}") + TopicEntity selectTopicById(TopicEntity topicEntity); + +} \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java new file mode 100644 index 00000000..d307d52f --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + +import java.util.List; + +/** + * Service About GroupMember + */ +public interface GroupMemberService { + + List getGroupMember(GroupMemberEntity groupMemberEntity); + + Integer addGroupMember(GroupMemberEntity groupMemberEntity); + + Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + + Integer deleteGroupMember(Long id); + + GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); + + List selectGroupMemberByGroup(GroupEntity groupEntity); + + List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java new file mode 100644 index 00000000..647dc5d3 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java @@ -0,0 +1,44 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; + + +import java.util.List; + +/** + * operate Group Service + */ + +public interface GroupService { + List getGroupList(GroupEntity groupEntity); + + Integer addGroup(GroupEntity groupEntity); + + Integer updateGroup(GroupEntity groupEntity); + + Integer deleteGroup(Long id); + + GroupEntity selectGroup(GroupEntity groupEntity); + + Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity); + + Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity); +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java new file mode 100644 index 00000000..4358c350 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java @@ -0,0 +1,79 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.annotation.EmLog; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; +import org.apache.eventmesh.dashboard.console.service.GroupMemberService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GroupMemberServiceImp implements GroupMemberService { + + @Autowired + OprGroupMemberDao oprGroupMemberDao; + + @Override + @EmLog(OprType = "View", OprTarget = "GroupMember") + public List getGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.getGroupList(groupMemberEntity); + } + + @Override + @EmLog(OprType = "add", OprTarget = "GroupMember") + public Integer addGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.addGroupMember(groupMemberEntity); + } + + @Override + public Integer updateGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.updateGroupMember(groupMemberEntity); + } + + @Override + public Integer deleteGroupMember(Long id) { + return oprGroupMemberDao.deleteGroupMember(id); + } + + @Override + public GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberDao.selectGroupMemberById(groupMemberEntity); + } + + @Override + public List selectGroupMemberByGroup(GroupEntity groupEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setGroupName(groupEntity.getName()); + groupMemberEntity.setClusterId(groupEntity.getClusterId()); + //Obtain a member who meets the conditions of a group + return oprGroupMemberDao.selectAllMemberByUnique(groupMemberEntity); + } + + @Override + public List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) { + List groupMemberEntities = oprGroupMemberDao.selectAllMemberByTopic(groupMemberEntity); + return groupMemberEntities; + } + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java new file mode 100644 index 00000000..69a2a18b --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java @@ -0,0 +1,98 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupDao; +import org.apache.eventmesh.dashboard.console.service.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.GroupService; + +import java.sql.Timestamp; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GroupServiceImpl implements GroupService { + + @Autowired + OprGroupDao oprGroupDao; + + @Autowired + GroupMemberService groupMemberService; + + @Override + public List getGroupList(GroupEntity groupEntity) { + return oprGroupDao.getGroupList(groupEntity); + + } + + @Override + public Integer addGroup(GroupEntity groupEntity) { + return oprGroupDao.addGroup(groupEntity); + } + + @Override + public Integer updateGroup(GroupEntity groupEntity) { + return oprGroupDao.updateGroup(groupEntity); + } + + @Override + public Integer deleteGroup(Long id) { + return oprGroupDao.deleteGroup(id); + } + + @Override + public GroupEntity selectGroup(GroupEntity groupEntity) { + return oprGroupDao.selectGroupById(groupEntity); + } + + @Override + public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) { + groupMemberService.addGroupMember(groupMemberEntity); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(groupMemberEntity.getGroupName()); + groupEntity.setClusterId(groupMemberEntity.getClusterId()); + GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + //^Obtain the group to which the member belongs + groupEntity1.setMembers(groupMemberEntity.getId() + "" + "," + groupEntity1.getMembers()); + //Concatenate the members of the group + groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); + groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + return oprGroupDao.updateGroup(groupEntity1); + //Modify the group member information + } + + @Override + public Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity) { + groupMemberService.deleteGroupMember(groupMemberEntity.getId()); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(groupMemberEntity.getGroupName()); + groupEntity.setClusterId(groupMemberEntity.getClusterId()); + GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + //^Obtain the group to which the member belongs + groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(groupMemberEntity.getId() + "" + ",", "")); + groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); + groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); + return oprGroupDao.updateGroup(groupEntity1); + } + + +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java new file mode 100644 index 00000000..6b922f1c --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java @@ -0,0 +1,83 @@ +/* + * 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.eventmesh.dashboard.console.service.Impl; + +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; +import org.apache.eventmesh.dashboard.console.mapper.TopicDao; +import org.apache.eventmesh.dashboard.console.service.TopicService; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class TopicServiceImpl implements TopicService { + + @Autowired + TopicDao topicDao; + + @Autowired + OprGroupMemberDao oprGroupMemberDao; + + + @Override + public List getTopicList(TopicEntity topicEntity) { + return topicDao.getTopicList(topicEntity); + } + + @Override + public Integer addTopic_plus(TopicEntity topicEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicEntity.getTopicName()); + groupMemberEntity.setState("active"); + oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); + return topicDao.addTopic(topicEntity); + } + + @Override + public Integer updateTopic(TopicEntity topicEntity) { + return topicDao.updateTopic(topicEntity); + } + + @Override + public Integer deleteTopic(Long id) { + return topicDao.deleteTopic(id); + } + + @Override + public TopicEntity selectTopicById(TopicEntity topicEntity) { + return topicDao.selectTopicById(topicEntity); + } + + @Override + public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { + return topicDao.selectTopicByUnique(topicEntity); + } + + @Override + public Integer deleteTopic_plus(TopicEntity topicEntity) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicEntity.getTopicName()); + groupMemberEntity.setState("empty"); + oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); + return topicDao.deleteTopic(topicEntity.getId()); + } +} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java new file mode 100644 index 00000000..b50b08d9 --- /dev/null +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java @@ -0,0 +1,41 @@ +/* + * 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.eventmesh.dashboard.console.service; + +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; + +import java.util.List; + +/** + * Service about Topic + */ +public interface TopicService { + List getTopicList(TopicEntity topicEntity); + + Integer addTopic_plus(TopicEntity topicEntity); + + Integer updateTopic(TopicEntity topicEntity); + + Integer deleteTopic(Long id); + + TopicEntity selectTopicById(TopicEntity topicEntity); + + TopicEntity selectTopicByUnique(TopicEntity topicEntity); + + Integer deleteTopic_plus(TopicEntity topicEntity); +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java new file mode 100644 index 00000000..8e5a6df9 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java @@ -0,0 +1,54 @@ +package org.apache.eventmesh.dashboard.console.linkage.GroupAndMemberAndTopicService; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.service.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.GroupService; +import org.apache.eventmesh.dashboard.console.service.TopicService; + +import java.sql.Timestamp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class testLinkedServiceOfTheThreeTable { + + @Autowired + private GroupMemberService groupMemberService; + + @Autowired + private GroupService groupService; + + @Autowired + private TopicService topicService; + @Test + private void testAddMemberIntoGroup(){ + GroupMemberEntity + groupMemberEntity = new GroupMemberEntity(1L,1L,"test2","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + groupService.insertMemberToGroup_plus(groupMemberEntity); + } + @Test + private void testDeleteMemberFromGroup(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setGroupName("z1"); + groupMemberEntity.setId(2L); + groupService.deleteMemberFromGroup_plus(groupMemberEntity); + } + @Test + public void testAddTopicForMember(){ + TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + topicService.addTopic_plus(topicEntity); + } + @Test + public void testDeleteTopicForMember(){ + TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + topicService.deleteTopic_plus(topicEntity); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java new file mode 100644 index 00000000..228978d7 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -0,0 +1,29 @@ +package org.apache.eventmesh.dashboard.console.linkage.log; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.service.GroupService; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class TestOprLog { + + @Autowired + private GroupService groupService; + + @Test + public void test_GroupService_OprLog(){ + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setClusterId(1L); + System.out.println(groupService.getGroupByClusterId(groupEntity)); + + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java new file mode 100644 index 00000000..86b36b98 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java @@ -0,0 +1,97 @@ +package org.apache.eventmesh.dashboard.console.unit.group; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupDao; +import org.apache.eventmesh.dashboard.console.service.GroupService; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class TestGroupDao { + + @Autowired + private OprGroupDao groupDao; + public List insertGroupData(String name){ + List groupEntities = new ArrayList<>(); + for(int i=0;i<10;i++){ + GroupEntity groupEntity = new GroupEntity(null, (long) i, name, 0, null, 1, "OK", null, null); + groupDao.addGroup(groupEntity); + groupEntities.add(groupEntity); + } + return groupEntities; + } + + public List getRemovedTimeList(String name){ + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(name); + List groupEntities = groupDao.selectGroupByDynamic(groupEntity); + for(GroupEntity groupEntity1:groupEntities){ + groupEntity1.setCreateTime(null); + groupEntity1.setUpdateTime(null); + } + return groupEntities; + } + @Test + public void testAddGroup(){ + List groupEntities = this.insertGroupData("addGroup"); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName("addGroup"); + List groupEntities1 = groupDao.selectGroupByDynamic(groupEntity); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup")); + } + @Test + public void testUpdateGroupById(){ + List groupEntities = this.insertGroupData("updateById2"); + GroupEntity groupEntity = groupEntities.get(9); + groupEntity.setType(3); + groupEntity.setMembers("1,"); + groupEntity.setState("fail"); + groupEntity.setMemberCount(1); + groupDao.updateGroup(groupEntity); + Assert.assertEquals(groupEntities,this.getRemovedTimeList("updateById2")); + } + @Test + public void testDeleteGroupById(){ + List groupEntities = this.insertGroupData("deleteById"); + GroupEntity groupEntity = groupEntities.get(9); + groupDao.deleteGroup(groupEntity); + groupEntities.remove(9); + Assert.assertEquals(groupEntities,this.getRemovedTimeList("deleteById")); + } + @Test + public void testSelectGroupById(){ + List groupEntities = this.insertGroupData("selectById"); + GroupEntity groupEntity = groupDao.selectGroupById(groupEntities.get(0)); + groupEntity.setCreateTime(null); + groupEntity.setUpdateTime(null); + Assert.assertEquals(groupEntities.get(0),groupEntity); + } + @Test + public void testSelectGroupByClusterId(){ + List groupEntities = this.insertGroupData("selectByUnique"); + GroupEntity groupEntity1 = new GroupEntity(); + groupEntity1.setClusterId(groupEntities.get(0).getClusterId()); + groupEntity1.setName(groupEntities.get(0).getName()); + GroupEntity groupEntity = groupDao.selectGroupByUnique(groupEntity1); + groupEntity.setCreateTime(null); + groupEntity.setUpdateTime(null); + Assert.assertEquals(groupEntities.get(0),groupEntity); + } + + @Test + public void test_selectGroupByDynamic(){ + List groupEntities = this.insertGroupData("selectByDynamic"); + Assert.assertEquals(groupEntities,this.getRemovedTimeList("Dynamic")); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java new file mode 100644 index 00000000..ab995e21 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java @@ -0,0 +1,99 @@ +package org.apache.eventmesh.dashboard.console.unit.groupmember; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class testGroupMemberDao { + + @Autowired + OprGroupMemberDao groupMemberDao; + + public List insertGroupData(String topicName,String groupName){ + List groupMemberEntities = new ArrayList<>(); + for(int i=0;i<10;i++){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(null,(long)i,topicName,groupName,"admin","active",null,null); + groupMemberDao.addGroupMember(groupMemberEntity); + groupMemberEntities.add(groupMemberEntity); + } + return groupMemberEntities; + } + + public List getRemovedTimeList(String topicName,String groupName){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicName); + groupMemberEntity.setGroupName(groupName); + List groupEntities = groupMemberDao.selectAllMemberByDynamic(groupMemberEntity); + for(GroupMemberEntity groupEntity1:groupEntities){ + groupEntity1.setCreateTime(null); + groupEntity1.setUpdateTime(null); + } + return groupEntities; + } + @Test + public void testAddGroupMember(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(1L,1L,"test_GroupMember","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + groupMemberDao.addGroupMember(groupMemberEntity); + } + @Test + public void testGetGroupMemberByClusterId(){ + GroupMemberEntity groupMemberEntity=new GroupMemberEntity(); + groupMemberEntity.setClusterId(1L); + System.out.println(groupMemberDao.getGroupByClusterId(groupMemberEntity)); + } + @Test + public void testDeleteGroupMemberById(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setId(1L); + groupMemberDao.deleteGroupMember(groupMemberEntity); + } + @Test + public void testUpdateGroupMemberById(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(1L,1L,"test_GroupMember","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + groupMemberDao.updateGroupMember(groupMemberEntity); + } + @Test + public void testSelectGroupMemberByUnique(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(1L,1L,"test_GroupMember","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + System.out.println(groupMemberDao.selectGroupMemberByUnique(groupMemberEntity)); + } + @Test + public void testSelectGroupMemberByGroup(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setClusterId(1L); + groupMemberEntity.setGroupName("z1"); + System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + } + + @Test + public void testSelectGroupMemberByTopic(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName("test_GroupMember"); + System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + } + @Test + public void testUpdateGroupMemberByTopic(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName("test_GroupMember"); + groupMemberDao.updateMemberByTopic(groupMemberEntity); + } + @Test + public void test_selectGroupMemberById(){ + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(1L,1L,"test_GroupMember","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + System.out.println(groupMemberDao.selectGroupMemberById(groupMemberEntity)); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java new file mode 100644 index 00000000..38e14594 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java @@ -0,0 +1,57 @@ +package org.apache.eventmesh.dashboard.console.unit.topic; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.TopicDao; + +import java.sql.Timestamp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class testTopicDao { + + @Autowired + private TopicDao topicDao; + @Test + public void testSelectTopicByClusterId(){ + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(1L); + System.out.println(topicDao.getTopicListByClusterId(topicEntity)); + } + @Test + public void testAddTopic(){ + TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + topicDao.addTopic(topicEntity); + } + @Test + public void testUpdateTopic(){ + TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + topicDao.updateTopic(topicEntity); + } + @Test + public void testDeleteTopic(){ + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(1L); + topicDao.deleteTopic(topicEntity); + } + @Test + public void testSelectTopicByUnique(){ + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(1L); + topicEntity.setTopicName("z1"); + System.out.println((topicDao.selectTopicByUnique(topicEntity))); + } + @Test + public void testSelectTopicById(){ + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(1L); + System.out.println(topicDao.selectTopicById(topicEntity)); + } + +} From 3391325d0a7e22a4a5ef11cd2f8a521ac87a78a1 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Thu, 1 Feb 2024 19:17:52 +0800 Subject: [PATCH 05/19] first improve --- .../EventMeshDashboardApplication.java | 37 --- .../console/EventmeshConsoleApplication.java | 7 +- .../dashboard/console/entity/GroupEntity.java | 1 - .../dashboard/console/entity/LogEntity.java | 2 + .../dashboard/console/log/OprLog.java | 100 ++++--- .../OprGroupMapper.java} | 47 +++- .../OprGroupMemberMapper.java} | 53 ++-- .../{OprLogDao.java => log/OprLogMapper.java} | 33 ++- .../{TopicDao.java => topic/TopicMapper.java} | 37 ++- .../service/{ => group}/GroupService.java | 11 +- .../{Impl => group}/GroupServiceImpl.java | 42 +-- .../{ => groupmember}/GroupMemberService.java | 10 +- .../GroupMemberServiceImp.java | 29 +- .../service => service/log}/LogService.java | 4 +- .../Impl => service/log}/LogServiceImpl.java | 15 +- .../service/{ => topic}/TopicService.java | 10 +- .../{Impl => topic}/TopicServiceImpl.java | 37 ++- .../main/resources/eventmesh-dashboard.sql | 266 +++++++++--------- .../console/linkage/log/TestOprLog.java | 28 ++ .../console/unit/group/TestGroupDao.java | 101 +++++++ .../unit/groupmember/testGroupMemberDao.java | 114 ++++++++ .../console/unit/topic/TestTopicMapper.java | 65 +++++ 22 files changed, 701 insertions(+), 348 deletions(-) delete mode 100644 eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/{OprGroupDao.java => group/OprGroupMapper.java} (51%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/{OprGroupMemberDao.java => groupmember/OprGroupMemberMapper.java} (53%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/{OprLogDao.java => log/OprLogMapper.java} (57%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/{TopicDao.java => topic/TopicMapper.java} (62%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{ => group}/GroupService.java (81%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{Impl => group}/GroupServiceImpl.java (68%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{ => groupmember}/GroupMemberService.java (76%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{Impl => groupmember}/GroupMemberServiceImp.java (66%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{log/service => service/log}/LogService.java (89%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{log/service/Impl => service/log}/LogServiceImpl.java (75%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{ => topic}/TopicService.java (80%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/{Impl => topic}/TopicServiceImpl.java (63%) create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java create mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java deleted file mode 100644 index 79fc03d8..00000000 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java +++ /dev/null @@ -1,37 +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. - */ - -package org.apache.eventmesh.dashboard.console; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; - -import lombok.extern.slf4j.Slf4j; - -@Slf4j -@SpringBootApplication -@EnableScheduling -@ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) -public class EventMeshDashboardApplication { - - public static void main(String[] args) { - SpringApplication.run(EventMeshDashboardApplication.class, args); - log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName()); - } -} diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java index 1e4d6dba..ffcfa646 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java @@ -17,14 +17,15 @@ package org.apache.eventmesh.dashboard.console; -import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import lombok.extern.slf4j.Slf4j; @Slf4j @SpringBootApplication -@ComponentScan({"org.apache.eventmesh.dashboard.service", "org.apache.eventmesh.dashboard.console"}) +@EnableTransactionManagement public class EventmeshConsoleApplication { public static void main(String[] args) { diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java index a394a397..4b5d6c6a 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java @@ -35,7 +35,6 @@ public class GroupEntity { private Integer memberCount; - private String members; private Integer type; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java index 7af7a276..c5ea1e21 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java @@ -44,5 +44,7 @@ public class LogEntity { private Timestamp endTime; + private String operationUser; + private String resultContent; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java index cad27277..db20f021 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -19,82 +19,102 @@ import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.LogEntity; -import org.apache.eventmesh.dashboard.console.log.service.LogService; +import org.apache.eventmesh.dashboard.console.service.log.LogService; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.sql.Timestamp; +import java.util.Objects; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; import org.springframework.core.Ordered; import org.springframework.stereotype.Service; import org.springframework.util.ClassUtils; @Aspect @Service -public class OprLog implements Ordered { +public class OprLog implements Ordered, ApplicationContextAware { private int order = LOWEST_PRECEDENCE - 1000; // Specify the order of execution - @Autowired private LogService logService; + private ApplicationContext applicationContext; + + @Pointcut("within(org.apache.eventmesh.dashboard.console.service..*)") public void pointCut() { } + @Around("pointCut()") public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { + if (Objects.isNull(this.logService)) { + this.logService = applicationContext.getBean(LogService.class); + } + EmLog declaredAnnotation = this.getTargetEmlog(joinPoint); + //Get the Emlog annotation on the method + if (Objects.isNull(declaredAnnotation)) { + return joinPoint.proceed(); + } + LogEntity logEntity = this.productLoEntity(declaredAnnotation, joinPoint); + logService.addLog(logEntity); + logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + try { + Object proceed = joinPoint.proceed(); + logEntity.setStatus(2); + logEntity.setResultContent(Objects.isNull(proceed) ? "" : proceed.toString()); + return proceed; + } catch (Throwable e) { + logEntity.setStatus(3); + throw new RuntimeException(e); + } finally { + logService.updateLog(logEntity); + } + + + } + + public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint joinPoint) throws NoSuchFieldException, IllegalAccessException { LogEntity logEntity = new LogEntity(); + Object[] args = joinPoint.getArgs(); + Object model = args[0]; + //Obtaining the Input Parameter of the Operation Method (Specified as the First) + Field clusterPhyId = model.getClass().getDeclaredField("clusterId"); + clusterPhyId.setAccessible(true); + Long opClusterPhyId = (Long) clusterPhyId.get(model); + //The clusterId is obtained from the parameter object, and the operation is described as the object itself + logEntity.setClusterId(opClusterPhyId); + logEntity.setDescription(model.toString()); + logEntity.setOperationType(declaredAnnotation.OprType()); + logEntity.setOperationTarget(declaredAnnotation.OprTarget()); + logEntity.setStatus(1); + logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); + return logEntity; + } + + public EmLog getTargetEmlog(ProceedingJoinPoint joinPoint) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); Method mostSpecificMethod = ClassUtils.getMostSpecificMethod(method, joinPoint.getTarget().getClass()); EmLog declaredAnnotation = mostSpecificMethod.getAnnotation(EmLog.class); - //Get the Emlog annotation on the method - if (declaredAnnotation != null) { - //It is a method of operation - logEntity.setOperationType(declaredAnnotation.OprType()); - logEntity.setOperationType(declaredAnnotation.OprTarget()); - Object[] args = joinPoint.getArgs(); - Object model = args[0]; - //Obtaining the Input Parameter of the Operation Method (Specified as the First) - Field clusterPhyId = model.getClass().getDeclaredField("clusterId"); - clusterPhyId.setAccessible(true); - Long opClusterPhyId = (Long) clusterPhyId.get(model); - String opDescription = model.toString(); - logEntity.setClusterId(opClusterPhyId); - logEntity.setDescription(opDescription); - //The clusterId is obtained from the parameter object, and the operation is described as the object itself - logEntity.setStatus(1); - logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); - logService.addLog(logEntity); - Object proceed = joinPoint.proceed(); - if (proceed == null) { - //An exception occurred with the target method - logEntity.setStatus(3); - logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); - Integer integer1 = logService.updateLog(logEntity); - return proceed; - } else { - //The target approach is successful - logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); - logEntity.setStatus(2); - Integer integer1 = logService.updateLog(logEntity); - return proceed; - } - } else { - //It is not part of the operation method - return joinPoint.proceed(); - } + return declaredAnnotation; } @Override public int getOrder() { return order; } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java similarity index 51% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java index abca67d3..2a2ae8e7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupDao.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/group/OprGroupMapper.java @@ -15,41 +15,60 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper; +package org.apache.eventmesh.dashboard.console.mapper.group; import org.apache.eventmesh.dashboard.console.entity.GroupEntity; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.util.List; /** -operate Group mapper + * operate Group mapper **/ @Mapper -public interface OprGroupDao { - @Select("select * from `group` where cluster_id=#{clusterId}") - List getGroupList(GroupEntity groupEntity); +public interface OprGroupMapper { - @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state, create_time, update_time)" - + "VALUE (#{clusterId},#{name},#{memberCount},#{Members},#{type},#{state},#{createTime},#{updateTime})") - Integer addGroup(GroupEntity groupEntity); + @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)" + + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " + + "on duplicate key update is_delete=0" + ) + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addGroup(GroupEntity groupEntity); - @Update("update `group`set cluster_id=#{clusterId},name=#{name},member_count=#{memberCount}," - + "members=#{Members},type=#{type},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") + @Update("update `group`set member_count=#{memberCount}," + + "members=#{members},type=#{type},state=#{state} where id=#{id}") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") Integer updateGroup(GroupEntity groupEntity); - @Delete("delete from `group` where id=#{id}") - Integer deleteGroup(Long id); + @Delete("update `group` set is_delete=1 where id=#{id}") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + Integer deleteGroup(GroupEntity groupEntity); - @Select("select * from `group` where cluster_id=#{clusterId} and name=#{name}") + @Select("select * from `group` where cluster_id=#{clusterId} and name=#{name} and is_delete=0") GroupEntity selectGroupByUnique(GroupEntity groupEntity); - @Select("select * from `group` where id=#{id}") + @Select("select * from `group` where id=#{id} and is_delete=0") GroupEntity selectGroupById(GroupEntity groupEntity); + @Select("") + List selectGroupByDynamic(GroupEntity groupEntity); + + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java similarity index 53% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java index 7c965919..ff58ef07 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprGroupMemberDao.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/groupmember/OprGroupMemberMapper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper; +package org.apache.eventmesh.dashboard.console.mapper.groupmember; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; @@ -23,30 +23,35 @@ import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.util.List; /** - operate GroupMember mapper + * operate GroupMember mapper **/ @Mapper -public interface OprGroupMemberDao { - @Select("select * from group_member where cluster_id=#{clusterId}") - List getGroupList(GroupMemberEntity groupMemberEntity); +public interface OprGroupMemberMapper { - @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user, state, create_time, update_time)" - + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state},#{createTime},#{updateTime})") - Integer addGroupMember(GroupMemberEntity groupMemberEntity); + @Select("select * from group_member where cluster_id=#{clusterId} and is_delete=0") + List getGroupByClusterId(GroupMemberEntity groupMemberEntity); - @Update("update group_member set cluster_id=#{clusterId},topic_name=#{topicName},group_name=#{groupName}" - + ",eventmesh_user=#{eventMeshUser},state=#{state},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") - Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user)" + + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser})" + + "on duplicate key update is_delete=0") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity); - @Delete("delete from group_member where id=#{id}") - Integer deleteGroupMember(Long id); + @Update("update group_member set state=#{state} where id=#{id}") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity); + + @Delete("update group_member set is_delete=1 where id=#{id} ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity); @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName}") GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); @@ -54,12 +59,22 @@ public interface OprGroupMemberDao { @Select("select * from group_member where id=#{id}") GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); - @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName}") - List selectAllMemberByUnique(GroupMemberEntity groupMemberEntity); - - @Select("select * from group_member where topic_name=#{topicName}") - List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity); + @Select("") + List selectAllMemberByDynamic(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where topic_name=#{topicName}") - Integer updateMemberByTopic(GroupMemberEntity groupMemberEntity); + GroupMemberEntity updateMemberByTopic(GroupMemberEntity groupMemberEntity); } \ No newline at end of file diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java similarity index 57% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java index 2c769772..240f85cd 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/OprLogDao.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/log/OprLogMapper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper; +package org.apache.eventmesh.dashboard.console.mapper.log; import org.apache.eventmesh.dashboard.console.entity.LogEntity; @@ -28,19 +28,30 @@ import java.util.List; /** - operate operationLog mapper + * operate operationLog mapper **/ @Mapper -public interface OprLogDao { - - @Select("select * from operation_log where cluster_id") - List getLogList(); - - @Insert("insert into operation_log ( cluster_id, operation_type, status, description, create_time) " - + "VALUE (#{clusterId},#{operationType},#{status},#{description},#{createTime})") - @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) +public interface OprLogMapper { + + @Select("") + List getLogList(LogEntity logEntity); + + @Insert("insert into operation_log ( cluster_id, operation_type,operation_target, description,operation_user)" + + "VALUE (#{clusterId},#{operationType},#{operationTarget},#{description},#{operationUser})") + @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) Long addLog(LogEntity logEntity); - @Update("update operation_log set status=#{status},end_time=#{endTime} where id=#{id}") + @Update("update operation_log set status=#{status} where id=#{id}") Integer updateLog(LogEntity logEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java similarity index 62% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java index c5c71036..b56b815b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/TopicDao.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/mapper/topic/TopicMapper.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.mapper; +package org.apache.eventmesh.dashboard.console.mapper.topic; import org.apache.eventmesh.dashboard.console.entity.TopicEntity; @@ -29,23 +29,34 @@ import java.util.List; /** - operate Topic mapper + * operate Topic mapper **/ @Mapper -public interface TopicDao { - @Select("select * from `topic` where cluster_id=#{clusterId}") - List getTopicList(TopicEntity topicEntity); +public interface TopicMapper { - @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description, create_time, update_time) " - + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description},#{createTime},#{updateTime})") - Integer addTopic(TopicEntity topicEntity); - @Update("update topic set cluster_id=#{clusterId},topic_name=#{topicName},runtime_id=#{runtimeId},storage_id=#{storageId}," - + "retention_ms=#{retentionMs},type=#{type},description=#{description},create_time=#{createTime},update_time=#{updateTime} where id=#{id}") - Integer updateTopic(TopicEntity topicEntity); + @Select("") + List getTopicListByClusterId(TopicEntity topicEntity); - @Delete("delete from `topic` where id=#{id}") - Integer deleteTopic(Long id); + @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " + + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})") + TopicEntity addTopic(TopicEntity topicEntity); + + @Update("update topic set type=#{type},description=#{description} where id=#{id}") + TopicEntity updateTopic(TopicEntity topicEntity); + + @Delete("update `topic` set is_delete=1 where id=#{id}") + TopicEntity deleteTopic(TopicEntity topicEntity); @Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}") TopicEntity selectTopicByUnique(TopicEntity topicEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java similarity index 81% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java index 647dc5d3..3aa5450c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service; +package org.apache.eventmesh.dashboard.console.service.group; import org.apache.eventmesh.dashboard.console.entity.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; @@ -28,13 +28,14 @@ */ public interface GroupService { - List getGroupList(GroupEntity groupEntity); - Integer addGroup(GroupEntity groupEntity); + List getGroupByClusterId(GroupEntity groupEntity); - Integer updateGroup(GroupEntity groupEntity); + GroupEntity addGroup(GroupEntity groupEntity); - Integer deleteGroup(Long id); + void updateGroup(GroupEntity groupEntity); + + Integer deleteGroup(GroupEntity groupEntity); GroupEntity selectGroup(GroupEntity groupEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java similarity index 68% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java index 69a2a18b..0952c679 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.Impl; +package org.apache.eventmesh.dashboard.console.service.group; +import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.OprGroupDao; -import org.apache.eventmesh.dashboard.console.service.GroupMemberService; -import org.apache.eventmesh.dashboard.console.service.GroupService; +import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; +import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; import java.sql.Timestamp; import java.util.List; @@ -33,35 +33,37 @@ public class GroupServiceImpl implements GroupService { @Autowired - OprGroupDao oprGroupDao; + OprGroupMapper oprGroupMapper; @Autowired GroupMemberService groupMemberService; + @EmLog(OprType = "search", OprTarget = "Group") @Override - public List getGroupList(GroupEntity groupEntity) { - return oprGroupDao.getGroupList(groupEntity); + public List getGroupByClusterId(GroupEntity groupEntity) { + return oprGroupMapper.selectGroupByDynamic(groupEntity); } @Override - public Integer addGroup(GroupEntity groupEntity) { - return oprGroupDao.addGroup(groupEntity); + public GroupEntity addGroup(GroupEntity groupEntity) { + oprGroupMapper.addGroup(groupEntity); + return groupEntity; } @Override - public Integer updateGroup(GroupEntity groupEntity) { - return oprGroupDao.updateGroup(groupEntity); + public void updateGroup(GroupEntity groupEntity) { + oprGroupMapper.updateGroup(groupEntity); } @Override - public Integer deleteGroup(Long id) { - return oprGroupDao.deleteGroup(id); + public Integer deleteGroup(GroupEntity groupEntity) { + return oprGroupMapper.deleteGroup(groupEntity); } @Override public GroupEntity selectGroup(GroupEntity groupEntity) { - return oprGroupDao.selectGroupById(groupEntity); + return oprGroupMapper.selectGroupById(groupEntity); } @Override @@ -70,28 +72,30 @@ public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) { GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(groupMemberEntity.getGroupName()); groupEntity.setClusterId(groupMemberEntity.getClusterId()); - GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + GroupEntity groupEntity1 = oprGroupMapper.selectGroupByUnique(groupEntity); //^Obtain the group to which the member belongs groupEntity1.setMembers(groupMemberEntity.getId() + "" + "," + groupEntity1.getMembers()); //Concatenate the members of the group groupEntity1.setMemberCount(groupEntity1.getMemberCount() + 1); groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); - return oprGroupDao.updateGroup(groupEntity1); + oprGroupMapper.updateGroup(groupEntity1); + return 1; //Modify the group member information } @Override public Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity) { - groupMemberService.deleteGroupMember(groupMemberEntity.getId()); + groupMemberService.deleteGroupMember(groupMemberEntity); GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(groupMemberEntity.getGroupName()); groupEntity.setClusterId(groupMemberEntity.getClusterId()); - GroupEntity groupEntity1 = oprGroupDao.selectGroupByUnique(groupEntity); + GroupEntity groupEntity1 = oprGroupMapper.selectGroupByUnique(groupEntity); //^Obtain the group to which the member belongs groupEntity1.setMembers(groupEntity1.getMembers().replaceAll(groupMemberEntity.getId() + "" + ",", "")); groupEntity1.setMemberCount(groupEntity1.getMemberCount() - 1); groupEntity1.setUpdateTime(new Timestamp(System.currentTimeMillis())); - return oprGroupDao.updateGroup(groupEntity1); + oprGroupMapper.updateGroup(groupEntity1); + return 1; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java similarity index 76% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java index d307d52f..d1881eeb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/GroupMemberService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service; +package org.apache.eventmesh.dashboard.console.service.groupmember; import org.apache.eventmesh.dashboard.console.entity.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; @@ -27,13 +27,13 @@ */ public interface GroupMemberService { - List getGroupMember(GroupMemberEntity groupMemberEntity); + List getGroupMemberByClusterId(GroupMemberEntity groupMemberEntity); - Integer addGroupMember(GroupMemberEntity groupMemberEntity); + GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity); - Integer updateGroupMember(GroupMemberEntity groupMemberEntity); + GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity); - Integer deleteGroupMember(Long id); + GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity); GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java similarity index 66% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java index 4358c350..2091aa99 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.Impl; +package org.apache.eventmesh.dashboard.console.service.groupmember; import org.apache.eventmesh.dashboard.console.annotation.EmLog; import org.apache.eventmesh.dashboard.console.entity.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; -import org.apache.eventmesh.dashboard.console.service.GroupMemberService; +import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; import java.util.List; @@ -32,33 +31,33 @@ public class GroupMemberServiceImp implements GroupMemberService { @Autowired - OprGroupMemberDao oprGroupMemberDao; + OprGroupMemberMapper oprGroupMemberMapper; @Override @EmLog(OprType = "View", OprTarget = "GroupMember") - public List getGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberDao.getGroupList(groupMemberEntity); + public List getGroupMemberByClusterId(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberMapper.getGroupByClusterId(groupMemberEntity); } @Override @EmLog(OprType = "add", OprTarget = "GroupMember") - public Integer addGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberDao.addGroupMember(groupMemberEntity); + public GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberMapper.addGroupMember(groupMemberEntity); } @Override - public Integer updateGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberDao.updateGroupMember(groupMemberEntity); + public GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberMapper.updateGroupMember(groupMemberEntity); } @Override - public Integer deleteGroupMember(Long id) { - return oprGroupMemberDao.deleteGroupMember(id); + public GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity) { + return oprGroupMemberMapper.deleteGroupMember(groupMemberEntity); } @Override public GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberDao.selectGroupMemberById(groupMemberEntity); + return oprGroupMemberMapper.selectGroupMemberById(groupMemberEntity); } @Override @@ -67,12 +66,12 @@ public List selectGroupMemberByGroup(GroupEntity groupEntity) groupMemberEntity.setGroupName(groupEntity.getName()); groupMemberEntity.setClusterId(groupEntity.getClusterId()); //Obtain a member who meets the conditions of a group - return oprGroupMemberDao.selectAllMemberByUnique(groupMemberEntity); + return oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); } @Override public List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) { - List groupMemberEntities = oprGroupMemberDao.selectAllMemberByTopic(groupMemberEntity); + List groupMemberEntities = oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); return groupMemberEntities; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java similarity index 89% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java index eac03df5..cc09a8e8 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/LogService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.log.service; +package org.apache.eventmesh.dashboard.console.service.log; import org.apache.eventmesh.dashboard.console.entity.LogEntity; @@ -29,7 +29,7 @@ public interface LogService { - List getLogListByCluster(); + List getLogListByCluster(LogEntity logEntity); Long addLog(LogEntity logEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java similarity index 75% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java index d19b0cab..b3d61534 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/service/Impl/LogServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.log.service.Impl; +package org.apache.eventmesh.dashboard.console.service.log; import org.apache.eventmesh.dashboard.console.entity.LogEntity; -import org.apache.eventmesh.dashboard.console.log.service.LogService; -import org.apache.eventmesh.dashboard.console.mapper.OprLogDao; +import org.apache.eventmesh.dashboard.console.mapper.log.OprLogMapper; import java.util.List; @@ -30,23 +29,23 @@ public class LogServiceImpl implements LogService { @Autowired - OprLogDao oprLogDao; + OprLogMapper oprLogMapper; @Override - public List getLogListByCluster() { + public List getLogListByCluster(LogEntity logEntity) { - return oprLogDao.getLogList(); + return oprLogMapper.getLogList(logEntity); } @Override public Long addLog(LogEntity logEntity) { - return oprLogDao.addLog(logEntity); + return oprLogMapper.addLog(logEntity); } @Override public Integer updateLog(LogEntity logEntity) { - return oprLogDao.updateLog(logEntity); + return oprLogMapper.updateLog(logEntity); } } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java similarity index 80% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java index b50b08d9..a7a823d3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service; +package org.apache.eventmesh.dashboard.console.service.topic; import org.apache.eventmesh.dashboard.console.entity.TopicEntity; @@ -27,15 +27,15 @@ public interface TopicService { List getTopicList(TopicEntity topicEntity); - Integer addTopic_plus(TopicEntity topicEntity); + TopicEntity addTopic_plus(TopicEntity topicEntity); - Integer updateTopic(TopicEntity topicEntity); + TopicEntity updateTopic(TopicEntity topicEntity); - Integer deleteTopic(Long id); + TopicEntity deleteTopic(TopicEntity topicEntity); TopicEntity selectTopicById(TopicEntity topicEntity); TopicEntity selectTopicByUnique(TopicEntity topicEntity); - Integer deleteTopic_plus(TopicEntity topicEntity); + TopicEntity deleteTopic_plus(TopicEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java similarity index 63% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java index 6b922f1c..7cc32ce0 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/Impl/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java @@ -15,13 +15,12 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.service.Impl; +package org.apache.eventmesh.dashboard.console.service.topic; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.entity.TopicEntity; -import org.apache.eventmesh.dashboard.console.mapper.OprGroupMemberDao; -import org.apache.eventmesh.dashboard.console.mapper.TopicDao; -import org.apache.eventmesh.dashboard.console.service.TopicService; +import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; +import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; import java.util.List; @@ -32,52 +31,52 @@ public class TopicServiceImpl implements TopicService { @Autowired - TopicDao topicDao; + TopicMapper topicMapper; @Autowired - OprGroupMemberDao oprGroupMemberDao; + OprGroupMemberMapper oprGroupMemberMapper; @Override public List getTopicList(TopicEntity topicEntity) { - return topicDao.getTopicList(topicEntity); + return topicMapper.getTopicListByClusterId(topicEntity); } @Override - public Integer addTopic_plus(TopicEntity topicEntity) { + public TopicEntity addTopic_plus(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("active"); - oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); - return topicDao.addTopic(topicEntity); + oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); + return topicMapper.addTopic(topicEntity); } @Override - public Integer updateTopic(TopicEntity topicEntity) { - return topicDao.updateTopic(topicEntity); + public TopicEntity updateTopic(TopicEntity topicEntity) { + return topicMapper.updateTopic(topicEntity); } @Override - public Integer deleteTopic(Long id) { - return topicDao.deleteTopic(id); + public TopicEntity deleteTopic(TopicEntity topicEntity) { + return topicMapper.deleteTopic(topicEntity); } @Override public TopicEntity selectTopicById(TopicEntity topicEntity) { - return topicDao.selectTopicById(topicEntity); + return topicMapper.selectTopicById(topicEntity); } @Override public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { - return topicDao.selectTopicByUnique(topicEntity); + return topicMapper.selectTopicByUnique(topicEntity); } @Override - public Integer deleteTopic_plus(TopicEntity topicEntity) { + public TopicEntity deleteTopic_plus(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("empty"); - oprGroupMemberDao.updateMemberByTopic(groupMemberEntity); - return topicDao.deleteTopic(topicEntity.getId()); + oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); + return topicMapper.deleteTopic(topicEntity); } } diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index a3715cb0..cf311b17 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -1,45 +1,86 @@ -create table operation_log +/* + * 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 `group` ( - id bigint unsigned auto_increment comment 'id' + id bigint unsigned auto_increment comment 'id' primary key, - cluster_id bigint default -1 not null comment '物理集群ID', - operation_type varchar(192) default '' not null comment '操作类型,如:启动,停止,重启,添加,删除,修改', - status int default 0 not null comment '操作状态 0:未知,1:执行中,2:成功,3:失败', - description text null comment '备注信息', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - end_time timestamp default CURRENT_TIMESTAMP null comment '结束时间' + cluster_id bigint default -1 not null comment '集群id', + name varchar(192) collate utf8_bin default '' not null comment 'Group名称', + member_count int unsigned default '0' not null comment '成员数', + members text null comment 'group的member列表', + type tinyint not null comment 'group类型 0:consumer 1:producer', + state varchar(64) default '' not null comment '状态', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', + update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', + is_delete int default 0 not null, + constraint uniq_cluster_phy_id_name + unique (cluster_id, name) ) - comment '操作记录信息表'; + comment 'Group信息表' engine = InnoDB; -create index idx_cluster_phy_id - on operation_log (cluster_id); +create index cluster_id + on `group` (cluster_id, name); -create index idx_status - on operation_log (status); +create table group_member +( + id bigint unsigned auto_increment comment 'id' + primary key, + cluster_id bigint default -1 not null comment '集群ID', + topic_name varchar(192) default '' not null comment 'Topic名称', + group_name varchar(192) default '' not null comment 'Group名称', + eventmesh_user varchar(192) default '' not null comment 'EventMesh用户', + state varchar(64) default '' not null comment '状态', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', + update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', + is_delete int default 0 not null, + constraint uniq_cluster_topic_group + unique (cluster_id, topic_name, group_name) +) + comment 'GroupMember信息表' engine = InnoDB; + +create index cluster_id + on group_member (cluster_id, topic_name, group_name); + -create table topic +create table operation_log ( - id bigint unsigned auto_increment comment 'id' + id bigint unsigned auto_increment comment 'id' primary key, - cluster_id bigint default -1 not null comment '集群ID', - topic_name varchar(192) collate utf8_bin default '' not null comment 'Topic名称', - runtime_id varchar(2048) default '' not null comment 'RuntimeId', - storage_id varchar(2048) default '' not null comment 'StorageId', - retention_ms bigint default -2 not null comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', - type tinyint default 0 not null comment 'Topic类型,默认0,0:普通,1:EventMesh内部', - description text null comment '备注信息', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间(尽量与Topic实际创建时间一致)', - update_time timestamp default CURRENT_TIMESTAMP not null comment '修改时间(尽量与Topic实际创建时间一致)', - constraint uniq_cluster_phy_id_topic_name - unique (cluster_id, topic_name) + cluster_id bigint default -1 not null comment '物理集群ID', + operation_type varchar(192) default '' not null comment '操作类型,如:启动,停止,重启,添加,删除,修改', + status int default 0 not null comment '操作状态 0:未知,1:执行中,2:成功,3:失败', + description text null comment '备注信息', + create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', + end_time timestamp default CURRENT_TIMESTAMP null comment '结束时间', + operation_user varchar(192) null, + result_content text null, + operation_target varchar(192) not null, + is_delete int not null ) - comment 'Topic信息表'; + comment '操作记录信息表' engine = InnoDB; -create index cluster_id - on topic (cluster_id, topic_name); +create index idx_cluster_phy_id + on operation_log (cluster_id); + +create index idx_status + on operation_log (status); @@ -56,77 +97,38 @@ create table topic description text null comment '备注信息', create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间(尽量与Topic实际创建时间一致)', update_time timestamp default CURRENT_TIMESTAMP not null comment '修改时间(尽量与Topic实际创建时间一致)', + is_delete int default 0 not null, constraint uniq_cluster_phy_id_topic_name unique (cluster_id, topic_name) ) - comment 'Topic信息表'; + comment 'Topic信息表' engine = InnoDB; create index cluster_id on topic (cluster_id, topic_name); - - -create table `group` -( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群id', - name varchar(192) collate utf8_bin default '' not null comment 'Group名称', - member_count int unsigned default '0' not null comment '成员数', - members text null comment 'group的member列表', - type tinyint not null comment 'group类型 0:consumer 1:producer', - state varchar(64) default '' not null comment '状态', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - constraint uniq_cluster_phy_id_name - unique (cluster_id, name) -) - comment 'Group信息表'; - -create index cluster_id - on `group` (cluster_id, name); - - -/* - * 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. - */ - DROP TABLE IF EXISTS `client`; CREATE TABLE `client` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端名称', - `platform` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端平台', - `language` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端语言', - `pid` bigint(22) NOT NULL DEFAULT '-1' COMMENT '客户端进程ID', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT '客户端地址', - `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 '客户端描述', - `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 '修改时间', + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', + `name` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端名称', + `platform` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端平台', + `language` varchar(192) NOT NULL DEFAULT '' COMMENT '客户端语言', + `pid` bigint(22) NOT NULL DEFAULT '-1' COMMENT '客户端进程ID', + `host` varchar(128) NOT NULL DEFAULT '' COMMENT '客户端地址', + `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 '客户端描述', + `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 '修改时间', PRIMARY KEY (`id`), - INDEX `idx_cluster_id` (`cluster_id`) + INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='客户端信息表'; @@ -135,16 +137,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` 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 '修改时间', PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`) ) ENGINE = InnoDB @@ -153,20 +155,20 @@ CREATE TABLE `connector` DROP TABLE IF EXISTS `connection`; CREATE TABLE `connection` ( - `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source类型,可以为client或source connector', - `source_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或source connector ID', - `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', - `sink_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或sink connector ID', - `runtime_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '对应runtime id', - `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 '客户端描述', - `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 '修改时间', + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', + `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source类型,可以为client或source connector', + `source_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或source connector ID', + `sink_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'sink类型,可以为client或sink connector', + `sink_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT 'client或sink connector ID', + `runtime_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '对应runtime id', + `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 '客户端描述', + `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 '修改时间', PRIMARY KEY (`id`), INDEX `idx_cluster_id` (`cluster_id`), @@ -180,14 +182,14 @@ CREATE TABLE `connection` DROP TABLE IF EXISTS `health_check_result`; CREATE TABLE `health_check_result` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', - `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知,1:Cluster,2:Runtime,3:Topic,4:Group)', - `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名', - `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', - `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称', - `passed` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查通过(0:未通过,1:通过)', - `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', + `dimension` int(11) NOT NULL DEFAULT '0' COMMENT '检查维度(0:未知,1:Cluster,2:Runtime,3:Topic,4:Group)', + `config_name` varchar(192) NOT NULL DEFAULT '' COMMENT '配置名', + `cluster_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '集群ID', + `res_name` varchar(192) NOT NULL DEFAULT '' COMMENT '资源名称', + `passed` tinyint(4) NOT NULL DEFAULT '0' COMMENT '检查通过(0:未通过,1:通过)', + `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`), UNIQUE KEY `uniq_dimension_config_cluster_res` (`dimension`, `config_name`, `cluster_id`, `res_name`) @@ -197,20 +199,20 @@ CREATE TABLE `health_check_result` DROP TABLE IF EXISTS `meta`; CREATE TABLE `meta` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', - `name` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心名称', - `type` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心类型,nacos,etcd,zookeeper', - `version` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心版本', - `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', - `host` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心地址', - `port` int(16) NOT NULL DEFAULT '-1' COMMENT '注册中心端口', - `role` varchar(16) NOT NULL DEFAULT '-1' COMMENT '角色, leader follower observer', - `username` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心用户名', - `params` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心启动参数', - `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', - - `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', + `name` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心名称', + `type` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心类型,nacos,etcd,zookeeper', + `version` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心版本', + `cluster_id` bigint(20) NOT NULL DEFAULT '-1' COMMENT '集群ID', + `host` varchar(128) NOT NULL DEFAULT '' COMMENT '注册中心地址', + `port` int(16) NOT NULL DEFAULT '-1' COMMENT '注册中心端口', + `role` varchar(16) NOT NULL DEFAULT '-1' COMMENT '角色, leader follower observer', + `username` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心用户名', + `params` varchar(192) NOT NULL DEFAULT '' COMMENT '注册中心启动参数', + `status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '状态: 1启用,0未启用', + + `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`) diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java new file mode 100644 index 00000000..cdebfb65 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -0,0 +1,28 @@ +package org.apache.eventmesh.dashboard.console.linkage.log; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.service.group.GroupService; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class TestOprLog { + + @Autowired + private GroupService groupService; + + @Test + public void test_groupService_OprLog() { + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setClusterId(1L); + System.out.println(groupService.getGroupByClusterId(groupEntity)); + + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java new file mode 100644 index 00000000..1c14ab13 --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java @@ -0,0 +1,101 @@ +package org.apache.eventmesh.dashboard.console.unit.group; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class TestGroupDao { + + @Autowired + private OprGroupMapper groupDao; + + public List insertGroupData(String name) { + List groupEntities = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + GroupEntity groupEntity = new GroupEntity(null, (long) i, name, 0, null, 1, "OK", null, null); + groupDao.addGroup(groupEntity); + groupEntities.add(groupEntity); + } + return groupEntities; + } + + public List getRemovedTimeList(String name) { + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName(name); + List groupEntities = groupDao.selectGroupByDynamic(groupEntity); + for (GroupEntity groupEntity1 : groupEntities) { + groupEntity1.setCreateTime(null); + groupEntity1.setUpdateTime(null); + } + return groupEntities; + } + + @Test + public void test_addGroup() { + List groupEntities = this.insertGroupData("addGroup"); + GroupEntity groupEntity = new GroupEntity(); + groupEntity.setName("addGroup"); + List groupEntities1 = groupDao.selectGroupByDynamic(groupEntity); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup")); + } + + @Test + public void test_updateGroupById() { + List groupEntities = this.insertGroupData("updateById2"); + GroupEntity groupEntity = groupEntities.get(9); + groupEntity.setType(3); + groupEntity.setMembers("1,"); + groupEntity.setState("fail"); + groupEntity.setMemberCount(1); + groupDao.updateGroup(groupEntity); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("updateById2")); + } + + @Test + public void test_deleteGroupById() { + List groupEntities = this.insertGroupData("deleteById"); + GroupEntity groupEntity = groupEntities.get(9); + groupDao.deleteGroup(groupEntity); + groupEntities.remove(9); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("deleteById")); + } + + @Test + public void test_selectGroupById() { + List groupEntities = this.insertGroupData("selectById"); + GroupEntity groupEntity = groupDao.selectGroupById(groupEntities.get(0)); + groupEntity.setCreateTime(null); + groupEntity.setUpdateTime(null); + Assert.assertEquals(groupEntities.get(0), groupEntity); + } + + @Test + public void test_selectGroupByClusterId() { + List groupEntities = this.insertGroupData("selectByUnique"); + GroupEntity groupEntity1 = new GroupEntity(); + groupEntity1.setClusterId(groupEntities.get(0).getClusterId()); + groupEntity1.setName(groupEntities.get(0).getName()); + GroupEntity groupEntity = groupDao.selectGroupByUnique(groupEntity1); + groupEntity.setCreateTime(null); + groupEntity.setUpdateTime(null); + Assert.assertEquals(groupEntities.get(0), groupEntity); + } + + @Test + public void test_selectGroupByDynamic() { + List groupEntities = this.insertGroupData("selectByDynamic"); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic")); + } +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java new file mode 100644 index 00000000..8ca2d34e --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java @@ -0,0 +1,114 @@ +package org.apache.eventmesh.dashboard.console.unit.groupmember; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; + +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class testGroupMemberDao { + + @Autowired + OprGroupMemberMapper groupMemberDao; + + public List insertGroupData(String topicName, String groupName) { + List groupMemberEntities = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(null, (long) i, topicName, groupName, "admin", "active", null, null); + groupMemberDao.addGroupMember(groupMemberEntity); + groupMemberEntities.add(groupMemberEntity); + } + return groupMemberEntities; + } + + public List getRemovedTimeList(String topicName, String groupName) { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName(topicName); + groupMemberEntity.setGroupName(groupName); + List groupEntities = groupMemberDao.selectAllMemberByDynamic(groupMemberEntity); + for (GroupMemberEntity groupEntity1 : groupEntities) { + groupEntity1.setCreateTime(null); + groupEntity1.setUpdateTime(null); + } + return groupEntities; + } + + @Test + public void testAddGroupMember() { + GroupMemberEntity groupMemberEntity = + new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + groupMemberDao.addGroupMember(groupMemberEntity); + } + + @Test + public void testGetGroupMemberByClusterId() { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setClusterId(1L); + System.out.println(groupMemberDao.getGroupByClusterId(groupMemberEntity)); + } + + @Test + public void testDeleteGroupMemberById() { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setId(1L); + groupMemberDao.deleteGroupMember(groupMemberEntity); + } + + @Test + public void testUpdateGroupMemberById() { + GroupMemberEntity groupMemberEntity = + new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + groupMemberDao.updateGroupMember(groupMemberEntity); + } + + @Test + public void testSelectGroupMemberByUnique() { + GroupMemberEntity groupMemberEntity = + new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + System.out.println(groupMemberDao.selectGroupMemberByUnique(groupMemberEntity)); + } + + @Test + public void testSelectGroupMemberByGroup() { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setClusterId(1L); + groupMemberEntity.setGroupName("z1"); + System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + } + + @Test + public void testSelectGroupMemberByTopic() { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName("test_GroupMember"); + System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + } + + @Test + public void testUpdateGroupMemberByTopic() { + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setTopicName("test_GroupMember"); + groupMemberDao.updateMemberByTopic(groupMemberEntity); + } + + @Test + public void test_selectGroupMemberById() { + GroupMemberEntity groupMemberEntity = + new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + System.out.println(groupMemberDao.selectGroupMemberById(groupMemberEntity)); + } + +} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java new file mode 100644 index 00000000..3d85404d --- /dev/null +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java @@ -0,0 +1,65 @@ +package org.apache.eventmesh.dashboard.console.unit.topic; + +import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; + +import java.sql.Timestamp; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = EventmeshConsoleApplication.class) +public class TestTopicMapper { + + @Autowired + private TopicMapper topicMapper; + + @Test + public void testSelectTopicByClusterId() { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(1L); + System.out.println(topicMapper.getTopicListByClusterId(topicEntity)); + } + + @Test + public void testAddTopic() { + TopicEntity topicEntity = new TopicEntity(1L, 1L, "z1", "10", "10", 100L, 1, "testTopic", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + topicMapper.addTopic(topicEntity); + } + + @Test + public void testUpdateTopic() { + TopicEntity topicEntity = new TopicEntity(1L, 1L, "z1", "10", "10", 100L, 1, "testTopic", new Timestamp(System.currentTimeMillis()), + new Timestamp(System.currentTimeMillis())); + topicMapper.updateTopic(topicEntity); + } + + @Test + public void testDeleteTopic() { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(1L); + topicMapper.deleteTopic(topicEntity); + } + + @Test + public void testSelectTopicByUnique() { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setClusterId(1L); + topicEntity.setTopicName("z1"); + System.out.println((topicMapper.selectTopicByUnique(topicEntity))); + } + + @Test + public void testSelectTopicById() { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setId(1L); + System.out.println(topicMapper.selectTopicById(topicEntity)); + } + +} From 0b172937b62abbaee8a3cd615ae23c6399518230 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Thu, 1 Feb 2024 19:36:10 +0800 Subject: [PATCH 06/19] second improve --- eventmesh-dashboard-common/pom.xml | 4 ---- eventmesh-dashboard-console/pom.xml | 4 ++-- eventmesh-dashboard-service/pom.xml | 4 ---- pom.xml | 32 +++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/eventmesh-dashboard-common/pom.xml b/eventmesh-dashboard-common/pom.xml index f79bd00c..52255b0a 100644 --- a/eventmesh-dashboard-common/pom.xml +++ b/eventmesh-dashboard-common/pom.xml @@ -20,10 +20,6 @@ - - junit - junit - org.projectlombok lombok diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index ea79bfe2..242c2550 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.apache.eventmesh.dashboard diff --git a/eventmesh-dashboard-service/pom.xml b/eventmesh-dashboard-service/pom.xml index 4c468287..f445adaf 100644 --- a/eventmesh-dashboard-service/pom.xml +++ b/eventmesh-dashboard-service/pom.xml @@ -18,8 +18,4 @@ UTF-8 - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index ed8fd4fb..59cb1874 100644 --- a/pom.xml +++ b/pom.xml @@ -89,6 +89,7 @@ eventmesh-dashboard-service eventmesh-dashboard-common + @@ -103,6 +104,37 @@ mybatis-spring-boot-starter ${mybatis-spring-boot.version} + + org.mybatis.spring.boot + mybatis-spring-boot-starter-test + ${mybatis-spring-boot.version} + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.3.1 + + style/checkStyle.xml + true + true + false + config_loc=style + + + + validate + validate + + check + + + + + + \ No newline at end of file From 22b8528bfdb590511414c898b066b32a3f23bb59 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Thu, 1 Feb 2024 19:38:12 +0800 Subject: [PATCH 07/19] third improve --- .../src/main/resources/application-dev.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 377c1334..00724de5 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -17,8 +17,6 @@ server: port: 9898 - servlet: - context-path: "/eventmesh" spring: servlet: @@ -46,10 +44,9 @@ spring: test-while-idle: true min-evictable-idle-time-millis: 300000 -mybatis: - type-aliases-package: org.apache.eventmesh.dashboard.console.entity - - - +# cron job config, use cron expression +cron: + #health check job + health: "0/15 * * * * ? *" From edb400576c0d12b15257b3a7084f32e932069305 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Thu, 1 Feb 2024 19:45:02 +0800 Subject: [PATCH 08/19] fourth improve --- eventmesh-dashboard-console/pom.xml | 6 ++++++ .../testLinkedServiceOfTheThreeTable.java | 7 ++++--- .../dashboard/console/unit/group/TestGroupDao.java | 6 +++--- .../dashboard/console/unit/topic/testTopicDao.java | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/eventmesh-dashboard-console/pom.xml b/eventmesh-dashboard-console/pom.xml index 242c2550..ddf65952 100644 --- a/eventmesh-dashboard-console/pom.xml +++ b/eventmesh-dashboard-console/pom.xml @@ -75,6 +75,12 @@ spring-aspects 5.1.2.RELEASE + + junit + junit + 4.13.2 + test + diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java index 8e5a6df9..c0b7dfb8 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java @@ -3,9 +3,10 @@ import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.entity.TopicEntity; -import org.apache.eventmesh.dashboard.console.service.GroupMemberService; -import org.apache.eventmesh.dashboard.console.service.GroupService; -import org.apache.eventmesh.dashboard.console.service.TopicService; +import org.apache.eventmesh.dashboard.console.service.group.GroupService; +import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; +import org.apache.eventmesh.dashboard.console.service.topic.TopicService; + import java.sql.Timestamp; diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java index 1c14ab13..e541e9e2 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java @@ -20,7 +20,7 @@ public class TestGroupDao { @Autowired private OprGroupMapper groupDao; - + public List insertGroupData(String name) { List groupEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { @@ -95,7 +95,7 @@ public void test_selectGroupByClusterId() { @Test public void test_selectGroupByDynamic() { - List groupEntities = this.insertGroupData("selectByDynamic"); - Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic")); + List groupEntities = this.insertGroupData("selectByDynamic1"); + Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic1")); } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java index 38e14594..d4c2b5a5 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java @@ -2,7 +2,7 @@ import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; import org.apache.eventmesh.dashboard.console.entity.TopicEntity; -import org.apache.eventmesh.dashboard.console.mapper.TopicDao; +import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; import java.sql.Timestamp; @@ -17,7 +17,7 @@ public class testTopicDao { @Autowired - private TopicDao topicDao; + private TopicMapper topicDao; @Test public void testSelectTopicByClusterId(){ TopicEntity topicEntity = new TopicEntity(); From c03085927c3da6343a1d345cafd03aa4c49ef804 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Fri, 2 Feb 2024 02:38:04 +0800 Subject: [PATCH 09/19] fourth improve --- .../console/service/group/GroupService.java | 4 +- .../service/group/GroupServiceImpl.java | 5 +- .../groupmember/GroupMemberService.java | 8 +- .../groupmember/GroupMemberServiceImp.java | 12 +- .../console/service/log/LogService.java | 2 +- .../console/service/log/LogServiceImpl.java | 2 +- .../console/service/topic/TopicService.java | 10 +- .../service/topic/TopicServiceImpl.java | 22 +-- .../main/resources/eventmesh-dashboard.sql | 165 +++++++++--------- .../testLinkedServiceOfTheThreeTable.java | 55 ------ .../console/linkage/log/TestOprLog.java | 25 ++- .../console/unit/group/TestGroupDao.java | 4 +- .../unit/groupmember/testGroupMemberDao.java | 101 +++++++---- .../console/unit/topic/TestTopicMapper.java | 65 ------- .../console/unit/topic/testTopicDao.java | 97 ++++++++-- 15 files changed, 275 insertions(+), 302 deletions(-) delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java delete mode 100644 eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java index 3aa5450c..953b582b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.service.group; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java index 0952c679..b849cac7 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java @@ -18,8 +18,8 @@ package org.apache.eventmesh.dashboard.console.service.group; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; @@ -45,6 +45,7 @@ public List getGroupByClusterId(GroupEntity groupEntity) { } + @EmLog(OprType = "add", OprTarget = "Group") @Override public GroupEntity addGroup(GroupEntity groupEntity) { oprGroupMapper.addGroup(groupEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java index d1881eeb..28f95168 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberService.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.service.groupmember; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import java.util.List; @@ -29,9 +29,9 @@ public interface GroupMemberService { List getGroupMemberByClusterId(GroupMemberEntity groupMemberEntity); - GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity); + void addGroupMember(GroupMemberEntity groupMemberEntity); - GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity); + void updateGroupMember(GroupMemberEntity groupMemberEntity); GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java index 2091aa99..f9815471 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java @@ -18,8 +18,8 @@ package org.apache.eventmesh.dashboard.console.service.groupmember; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; import java.util.List; @@ -41,13 +41,13 @@ public List getGroupMemberByClusterId(GroupMemberEntity group @Override @EmLog(OprType = "add", OprTarget = "GroupMember") - public GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.addGroupMember(groupMemberEntity); + public void addGroupMember(GroupMemberEntity groupMemberEntity) { + oprGroupMemberMapper.addGroupMember(groupMemberEntity); } @Override - public GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity) { - return oprGroupMemberMapper.updateGroupMember(groupMemberEntity); + public void updateGroupMember(GroupMemberEntity groupMemberEntity) { + oprGroupMemberMapper.updateGroupMember(groupMemberEntity); } @Override diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java index cc09a8e8..d496ae6e 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogService.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.service.log; -import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java index b3d61534..7bd680be 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/log/LogServiceImpl.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.service.log; -import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.eventmesh.dashboard.console.mapper.log.OprLogMapper; import java.util.List; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java index a7a823d3..86abdb83 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.service.topic; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import java.util.List; @@ -27,15 +27,15 @@ public interface TopicService { List getTopicList(TopicEntity topicEntity); - TopicEntity addTopic_plus(TopicEntity topicEntity); + void addTopic_plus(TopicEntity topicEntity); - TopicEntity updateTopic(TopicEntity topicEntity); + void updateTopic(TopicEntity topicEntity); - TopicEntity deleteTopic(TopicEntity topicEntity); + void deleteTopic(TopicEntity topicEntity); TopicEntity selectTopicById(TopicEntity topicEntity); TopicEntity selectTopicByUnique(TopicEntity topicEntity); - TopicEntity deleteTopic_plus(TopicEntity topicEntity); + void deleteTopic_plus(TopicEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java index 7cc32ce0..a4c1c11d 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java @@ -17,8 +17,8 @@ package org.apache.eventmesh.dashboard.console.service.topic; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; @@ -39,26 +39,26 @@ public class TopicServiceImpl implements TopicService { @Override public List getTopicList(TopicEntity topicEntity) { - return topicMapper.getTopicListByClusterId(topicEntity); + return topicMapper.getTopicListByDynamic(topicEntity); } @Override - public TopicEntity addTopic_plus(TopicEntity topicEntity) { + public void addTopic_plus(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("active"); oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); - return topicMapper.addTopic(topicEntity); + topicMapper.addTopic(topicEntity); } @Override - public TopicEntity updateTopic(TopicEntity topicEntity) { - return topicMapper.updateTopic(topicEntity); + public void updateTopic(TopicEntity topicEntity) { + topicMapper.updateTopic(topicEntity); } @Override - public TopicEntity deleteTopic(TopicEntity topicEntity) { - return topicMapper.deleteTopic(topicEntity); + public void deleteTopic(TopicEntity topicEntity) { + topicMapper.deleteTopic(topicEntity); } @Override @@ -72,11 +72,11 @@ public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { } @Override - public TopicEntity deleteTopic_plus(TopicEntity topicEntity) { + public void deleteTopic_plus(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("empty"); oprGroupMemberMapper.updateMemberByTopic(groupMemberEntity); - return topicMapper.deleteTopic(topicEntity); + topicMapper.deleteTopic(topicEntity); } } diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index cf311b17..4699e7a6 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -14,97 +14,88 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -create table `group` +CREATE TABLE `group` ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群id', - name varchar(192) collate utf8_bin default '' not null comment 'Group名称', - member_count int unsigned default '0' not null comment '成员数', - members text null comment 'group的member列表', - type tinyint not null comment 'group类型 0:consumer 1:producer', - state varchar(64) default '' not null comment '状态', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - is_delete int default 0 not null, - constraint uniq_cluster_phy_id_name - unique (cluster_id, name) -) - comment 'Group信息表' engine = InnoDB; - -create index cluster_id - on `group` (cluster_id, name); - - - -create table group_member + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `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列表', + `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 '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间', + `is_delete` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_cluster_phy_id_name` (`cluster_id`, `name`), + KEY `cluster_id` (`cluster_id`, `name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 322 + DEFAULT CHARSET = utf8mb3 COMMENT ='Group信息表' + + + +CREATE TABLE `group_member` ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群ID', - topic_name varchar(192) default '' not null comment 'Topic名称', - group_name varchar(192) default '' not null comment 'Group名称', - eventmesh_user varchar(192) default '' not null comment 'EventMesh用户', - state varchar(64) default '' not null comment '状态', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - update_time timestamp default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '修改时间', - is_delete int default 0 not null, - constraint uniq_cluster_topic_group - unique (cluster_id, topic_name, group_name) -) - comment 'GroupMember信息表' engine = InnoDB; - -create index cluster_id - on group_member (cluster_id, topic_name, group_name); - - - -create table operation_log + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', + `topic_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Topic名称', + `group_name` varchar(192) NOT NULL DEFAULT '' COMMENT 'Group名称', + `eventmesh_user` varchar(192) NOT NULL DEFAULT '' COMMENT 'EventMesh用户', + `state` varchar(64) 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 '修改时间', + `is_delete` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_cluster_topic_group` (`cluster_id`, `topic_name`, `group_name`), + KEY `cluster_id` (`cluster_id`, `topic_name`, `group_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 257 + DEFAULT CHARSET = utf8mb3 COMMENT ='GroupMember信息表' + + + +CREATE TABLE `operation_log` ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '物理集群ID', - operation_type varchar(192) default '' not null comment '操作类型,如:启动,停止,重启,添加,删除,修改', - status int default 0 not null comment '操作状态 0:未知,1:执行中,2:成功,3:失败', - description text null comment '备注信息', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间', - end_time timestamp default CURRENT_TIMESTAMP null comment '结束时间', - operation_user varchar(192) null, - result_content text null, - operation_target varchar(192) not null, - is_delete int not null -) - comment '操作记录信息表' engine = InnoDB; - -create index idx_cluster_phy_id - on operation_log (cluster_id); - -create index idx_status - on operation_log (status); - - - -create table topic + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `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:失败', + `description` text 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_content` text, + `target_type` varchar(192) NOT NULL, + `is_delete` int NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + KEY `idx_cluster_phy_id` (`cluster_id`), + KEY `idx_status` (`status`) +) ENGINE = InnoDB + AUTO_INCREMENT = 68 + DEFAULT CHARSET = utf8mb3 COMMENT ='操作记录信息表' + + + +CREATE TABLE `topic` ( - id bigint unsigned auto_increment comment 'id' - primary key, - cluster_id bigint default -1 not null comment '集群ID', - topic_name varchar(192) collate utf8_bin default '' not null comment 'Topic名称', - runtime_id varchar(2048) default '' not null comment 'RuntimeId', - storage_id varchar(2048) default '' not null comment 'StorageId', - retention_ms bigint default -2 not null comment '保存时间,-2:未知,-1:无限制,>=0对应时间,单位ms', - type tinyint default 0 not null comment 'Topic类型,默认0,0:普通,1:EventMesh内部', - description text null comment '备注信息', - create_time timestamp default CURRENT_TIMESTAMP not null comment '创建时间(尽量与Topic实际创建时间一致)', - update_time timestamp default CURRENT_TIMESTAMP not null comment '修改时间(尽量与Topic实际创建时间一致)', - is_delete int default 0 not null, - constraint uniq_cluster_phy_id_topic_name - unique (cluster_id, topic_name) -) - comment 'Topic信息表' engine = InnoDB; - -create index cluster_id - on topic (cluster_id, topic_name); + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `cluster_id` bigint NOT NULL DEFAULT '-1' COMMENT '集群ID', + `topic_name` varchar(192) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Topic名称', + `runtime_id` varchar(2048) NOT NULL DEFAULT '' COMMENT 'RuntimeId', + `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 '备注信息', + `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', + PRIMARY KEY (`id`), + UNIQUE KEY `uniq_cluster_phy_id_topic_name` (`cluster_id`, `topic_name`), + KEY `cluster_id` (`cluster_id`, `topic_name`) +) ENGINE = InnoDB + AUTO_INCREMENT = 562 + DEFAULT CHARSET = utf8mb3 COMMENT ='Topic信息表' diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java deleted file mode 100644 index c0b7dfb8..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/GroupAndMemberAndTopicService/testLinkedServiceOfTheThreeTable.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.eventmesh.dashboard.console.linkage.GroupAndMemberAndTopicService; - -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; -import org.apache.eventmesh.dashboard.console.service.group.GroupService; -import org.apache.eventmesh.dashboard.console.service.groupmember.GroupMemberService; -import org.apache.eventmesh.dashboard.console.service.topic.TopicService; - - -import java.sql.Timestamp; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) -public class testLinkedServiceOfTheThreeTable { - - @Autowired - private GroupMemberService groupMemberService; - - @Autowired - private GroupService groupService; - - @Autowired - private TopicService topicService; - @Test - private void testAddMemberIntoGroup(){ - GroupMemberEntity - groupMemberEntity = new GroupMemberEntity(1L,1L,"test2","z1","admin","active",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); - groupService.insertMemberToGroup_plus(groupMemberEntity); - } - @Test - private void testDeleteMemberFromGroup(){ - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setGroupName("z1"); - groupMemberEntity.setId(2L); - groupService.deleteMemberFromGroup_plus(groupMemberEntity); - } - @Test - public void testAddTopicForMember(){ - TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); - topicService.addTopic_plus(topicEntity); - } - @Test - public void testDeleteTopicForMember(){ - TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); - topicService.deleteTopic_plus(topicEntity); - } - -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java index cdebfb65..604e8c86 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -1,9 +1,14 @@ package org.apache.eventmesh.dashboard.console.linkage.log; import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.eventmesh.dashboard.console.service.group.GroupService; +import org.apache.eventmesh.dashboard.console.service.log.LogService; +import java.util.List; + +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -17,12 +22,22 @@ public class TestOprLog { @Autowired private GroupService groupService; + @Autowired + private LogService logService; + @Test public void test_groupService_OprLog() { - GroupEntity groupEntity = new GroupEntity(); - groupEntity.setClusterId(1L); - System.out.println(groupService.getGroupByClusterId(groupEntity)); - + GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null); + GroupEntity groupEntity1 = groupService.addGroup(groupEntity); + LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity1.toString(), null, null, null, null); + logEntity.setResultContent(groupEntity.toString()); + logEntity.setId(groupEntity1.getId()); + List logListByCluster = logService.getLogListByCluster(logEntity); + logListByCluster.get(0).setId(null); + logListByCluster.get(0).setCreateTime(null); + logListByCluster.get(0).setEndTime(null); + Assert.assertEquals(logListByCluster.get(0), logEntity); + Assert.assertEquals(logListByCluster.size(), 1); } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java index e541e9e2..e1276e8e 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java @@ -1,7 +1,7 @@ package org.apache.eventmesh.dashboard.console.unit.group; import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; import java.util.ArrayList; @@ -20,7 +20,7 @@ public class TestGroupDao { @Autowired private OprGroupMapper groupDao; - + public List insertGroupData(String name) { List groupEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java index 8ca2d34e..3a57bcee 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java @@ -1,13 +1,13 @@ package org.apache.eventmesh.dashboard.console.unit.groupmember; import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; -import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -44,71 +44,98 @@ public List getRemovedTimeList(String topicName, String group } @Test - public void testAddGroupMember() { - GroupMemberEntity groupMemberEntity = - new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); - groupMemberDao.addGroupMember(groupMemberEntity); + public void test_addGroupMember() { + List add1 = this.insertGroupData("add1", "groupMember"); + Assert.assertEquals(add1, this.getRemovedTimeList("add1", "groupMember")); } @Test - public void testGetGroupMemberByClusterId() { + public void test_getGroupMemberByClusterId() { + List add1 = this.insertGroupData("getByCluster", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setClusterId(1L); - System.out.println(groupMemberDao.getGroupByClusterId(groupMemberEntity)); + groupMemberEntity.setClusterId(add1.get(1).getClusterId()); + List groupByClusterId = groupMemberDao.getGroupByClusterId(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupByClusterId.get(0); + groupMemberEntity1.setCreateTime(null); + groupMemberEntity1.setUpdateTime(null); + Assert.assertEquals(1, groupByClusterId.size()); + Assert.assertEquals(add1.get(1), groupMemberEntity1); } @Test - public void testDeleteGroupMemberById() { + public void test_deleteGroupMemberById() { + List add1 = this.insertGroupData("getById", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setId(1L); - groupMemberDao.deleteGroupMember(groupMemberEntity); + groupMemberEntity.setId(add1.get(2).getId()); + GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(groupMemberEntity); + groupMemberEntity1.setUpdateTime(null); + groupMemberEntity1.setCreateTime(null); + Assert.assertEquals(groupMemberEntity1, add1.get(2)); } @Test - public void testUpdateGroupMemberById() { - GroupMemberEntity groupMemberEntity = - new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); + public void test_updateGroupMemberById() { + List add1 = this.insertGroupData("updateById", "groupMember"); + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + add1.get(1).setState("fail1"); + groupMemberEntity.setState("fail1"); + groupMemberEntity.setId(add1.get(1).getId()); groupMemberDao.updateGroupMember(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(add1.get(1)); + groupMemberEntity1.setUpdateTime(null); + groupMemberEntity1.setCreateTime(null); + Assert.assertEquals(groupMemberEntity1, add1.get(1)); } @Test - public void testSelectGroupMemberByUnique() { - GroupMemberEntity groupMemberEntity = - new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); - System.out.println(groupMemberDao.selectGroupMemberByUnique(groupMemberEntity)); + public void test_selectGroupMemberByUnique() { + List groupMemberEntities = this.insertGroupData("selectByUnique", "groupMember"); + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setClusterId(groupMemberEntities.get(1).getClusterId()); + groupMemberEntity.setTopicName(groupMemberEntities.get(1).getTopicName()); + groupMemberEntity.setGroupName(groupMemberEntities.get(1).getGroupName()); + GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberByUnique(groupMemberEntity); + groupMemberEntity1.setUpdateTime(null); + groupMemberEntity1.setCreateTime(null); + Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(1)); } @Test - public void testSelectGroupMemberByGroup() { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setClusterId(1L); - groupMemberEntity.setGroupName("z1"); - System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + public void test_selectGroupMemberByGroup() { + List groupMemberEntities = this.insertGroupData("selectByGroup1", "groupMember1"); + List removedTimeList = this.getRemovedTimeList(null, "groupMember1"); + Assert.assertEquals(groupMemberEntities, removedTimeList); } @Test - public void testSelectGroupMemberByTopic() { - GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setTopicName("test_GroupMember"); - System.out.println(groupMemberDao.selectAllMemberByDynamic(groupMemberEntity)); + public void test_selectGroupMemberByTopic() { + List groupMemberEntities = this.insertGroupData("selectByTopic1", "groupMember2"); + List removedTimeList = this.getRemovedTimeList("selectByTopic1", null); + Assert.assertEquals(groupMemberEntities, removedTimeList); } @Test - public void testUpdateGroupMemberByTopic() { + public void test_updateGroupMemberByTopic() { + List groupMemberEntities = this.insertGroupData("updateByTopic1", "groupMember2"); + for (GroupMemberEntity groupMemberEntity : groupMemberEntities) { + groupMemberEntity.setState("fail2"); + } GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); - groupMemberEntity.setTopicName("test_GroupMember"); + groupMemberEntity.setState("fail2"); + groupMemberEntity.setTopicName("updateByTopic1"); groupMemberDao.updateMemberByTopic(groupMemberEntity); + Assert.assertEquals(this.getRemovedTimeList("updateByTopic1", null), groupMemberEntities); } @Test public void test_selectGroupMemberById() { - GroupMemberEntity groupMemberEntity = - new GroupMemberEntity(1L, 1L, "test_GroupMember", "z1", "admin", "active", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); - System.out.println(groupMemberDao.selectGroupMemberById(groupMemberEntity)); + List groupMemberEntities = this.insertGroupData("updateById1", "groupMember2"); + GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); + groupMemberEntity.setId(groupMemberEntities.get(5).getId()); + GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(groupMemberEntity); + groupMemberEntity1.setCreateTime(null); + groupMemberEntity1.setUpdateTime(null); + Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(5)); } } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java deleted file mode 100644 index 3d85404d..00000000 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/TestTopicMapper.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.eventmesh.dashboard.console.unit.topic; - -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; -import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; - -import java.sql.Timestamp; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) -public class TestTopicMapper { - - @Autowired - private TopicMapper topicMapper; - - @Test - public void testSelectTopicByClusterId() { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(1L); - System.out.println(topicMapper.getTopicListByClusterId(topicEntity)); - } - - @Test - public void testAddTopic() { - TopicEntity topicEntity = new TopicEntity(1L, 1L, "z1", "10", "10", 100L, 1, "testTopic", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); - topicMapper.addTopic(topicEntity); - } - - @Test - public void testUpdateTopic() { - TopicEntity topicEntity = new TopicEntity(1L, 1L, "z1", "10", "10", 100L, 1, "testTopic", new Timestamp(System.currentTimeMillis()), - new Timestamp(System.currentTimeMillis())); - topicMapper.updateTopic(topicEntity); - } - - @Test - public void testDeleteTopic() { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(1L); - topicMapper.deleteTopic(topicEntity); - } - - @Test - public void testSelectTopicByUnique() { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(1L); - topicEntity.setTopicName("z1"); - System.out.println((topicMapper.selectTopicByUnique(topicEntity))); - } - - @Test - public void testSelectTopicById() { - TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(1L); - System.out.println(topicMapper.selectTopicById(topicEntity)); - } - -} diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java index d4c2b5a5..b60da0d4 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java @@ -1,11 +1,13 @@ package org.apache.eventmesh.dashboard.console.unit.topic; import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; -import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -18,40 +20,97 @@ public class testTopicDao { @Autowired private TopicMapper topicDao; + + public List insertGroupData(String topicName) { + List topicEntities = new ArrayList<>(); + for (int i = 0; i < 10; i++) { + TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", "10", 100L, 1, "testTopic", null, null); + topicDao.addTopic(topicEntity); + topicEntities.add(topicEntity); + } + return topicEntities; + } + + public List getRemovedTimeList(String topicName, Long clusterId) { + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setTopicName(topicName); + topicEntity.setClusterId(clusterId); + List topicEntities = topicDao.getTopicListByDynamic(topicEntity); + for (TopicEntity topic : topicEntities) { + topic.setCreateTime(null); + topic.setUpdateTime(null); + } + return topicEntities; + } + @Test - public void testSelectTopicByClusterId(){ + public void test_selectTopicByClusterId() { + List topicEntities = this.insertGroupData("SelectById111"); TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(1L); - System.out.println(topicDao.getTopicListByClusterId(topicEntity)); + topicEntity.setClusterId(topicEntities.get(9).getClusterId()); + List topicEntity1 = topicDao.getTopicListByDynamic(topicEntity); + topicEntity1.get(0).setCreateTime(null); + topicEntity1.get(0).setUpdateTime(null); + Assert.assertEquals(topicEntity1.get(0), topicEntities.get(9)); + Assert.assertEquals(1, topicEntity1.size()); } + @Test - public void testAddTopic(){ - TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); - topicDao.addTopic(topicEntity); + public void test_addTopic() { + List topicEntities = this.insertGroupData("add111"); + List add111 = this.getRemovedTimeList("add111", null); + Assert.assertEquals(add111, topicEntities); } + @Test - public void testUpdateTopic(){ - TopicEntity topicEntity = new TopicEntity(1L,1L,"z1","10","10",100L,1,"testTopic",new Timestamp(System.currentTimeMillis()),new Timestamp(System.currentTimeMillis())); + public void test_UpdateTopic() { + List topicEntities = this.insertGroupData("update2"); + topicEntities.get(5).setDescription("updateTest1"); + topicEntities.get(5).setType(-1); + TopicEntity topicEntity = new TopicEntity(); + topicEntity.setDescription("updateTest1"); + topicEntity.setType(-1); + topicEntity.setId(topicEntities.get(5).getId()); topicDao.updateTopic(topicEntity); + TopicEntity topicEntity1 = topicDao.selectTopicById(topicEntity); + topicEntity1.setUpdateTime(null); + topicEntity1.setCreateTime(null); + Assert.assertEquals(topicEntity1, topicEntities.get(5)); } + @Test - public void testDeleteTopic(){ + public void test_DeleteTopic() { + List topicEntities = this.insertGroupData("update72"); TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(1L); + topicEntity.setId(topicEntities.get(5).getId()); + topicEntity.setClusterId(topicEntities.get(5).getClusterId()); + topicEntity.setTopicName("update72"); topicDao.deleteTopic(topicEntity); + List topicEntity1 = topicDao.getTopicListByDynamic(topicEntity); + Assert.assertEquals(true, topicEntity1.isEmpty()); } + @Test - public void testSelectTopicByUnique(){ + public void test_selectTopicByUnique() { + List topicEntities = this.insertGroupData("unique11"); TopicEntity topicEntity = new TopicEntity(); - topicEntity.setClusterId(1L); - topicEntity.setTopicName("z1"); - System.out.println((topicDao.selectTopicByUnique(topicEntity))); + topicEntity.setTopicName("unique11"); + topicEntity.setClusterId(topicEntities.get(1).getClusterId()); + TopicEntity topicEntity1 = topicDao.selectTopicByUnique(topicEntity); + topicEntity1.setUpdateTime(null); + topicEntity1.setCreateTime(null); + Assert.assertEquals(topicEntity1, topicEntities.get(1)); } + @Test - public void testSelectTopicById(){ + public void test_selectTopicById() { + List topicEntities = this.insertGroupData("id1"); TopicEntity topicEntity = new TopicEntity(); - topicEntity.setId(1L); - System.out.println(topicDao.selectTopicById(topicEntity)); + topicEntity.setId(topicEntities.get(2).getId()); + TopicEntity topicEntity1 = topicDao.selectTopicById(topicEntity); + topicEntity1.setCreateTime(null); + topicEntity1.setUpdateTime(null); + Assert.assertEquals(topicEntity1, topicEntities.get(2)); } } From a6b5caaa9ddc9055e55228fdc9af86f68ee2f6f1 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Fri, 2 Feb 2024 02:39:09 +0800 Subject: [PATCH 10/19] fourth improve --- .../entity/{ => group}/GroupEntity.java | 2 +- .../{ => groupmember}/GroupMemberEntity.java | 2 +- .../console/entity/{ => log}/LogEntity.java | 5 ++-- .../entity/{ => topic}/TopicEntity.java | 2 +- .../dashboard/console/log/OprLog.java | 8 ++++--- .../console/mapper/group/OprGroupMapper.java | 5 ++-- .../groupmember/OprGroupMemberMapper.java | 17 ++++++------- .../console/mapper/log/OprLogMapper.java | 23 ++++++++++-------- .../console/mapper/topic/TopicMapper.java | 24 +++++++++++-------- 9 files changed, 49 insertions(+), 39 deletions(-) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/{ => group}/GroupEntity.java (95%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/{ => groupmember}/GroupMemberEntity.java (94%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/{ => log}/LogEntity.java (93%) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/{ => topic}/TopicEntity.java (95%) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java similarity index 95% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java index 4b5d6c6a..c395bac3 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/group/GroupEntity.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity; +package org.apache.eventmesh.dashboard.console.entity.group; import java.sql.Timestamp; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java similarity index 94% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java index 9433d6d0..dbadc1eb 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/GroupMemberEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/groupmember/GroupMemberEntity.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity; +package org.apache.eventmesh.dashboard.console.entity.groupmember; import java.sql.Timestamp; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java similarity index 93% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java index c5ea1e21..49e3c236 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/LogEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity; +package org.apache.eventmesh.dashboard.console.entity.log; import java.sql.Timestamp; @@ -34,7 +34,7 @@ public class LogEntity { private String operationType; - private String operationTarget; + private String targetType; private Integer status; @@ -47,4 +47,5 @@ public class LogEntity { private String operationUser; private String resultContent; + } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java similarity index 95% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java index 94f1de6c..6b4bd09c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/TopicEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/topic/TopicEntity.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.eventmesh.dashboard.console.entity; +package org.apache.eventmesh.dashboard.console.entity.topic; import java.sql.Timestamp; diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java index db20f021..11762d24 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -18,7 +18,7 @@ package org.apache.eventmesh.dashboard.console.log; import org.apache.eventmesh.dashboard.console.annotation.EmLog; -import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.eventmesh.dashboard.console.service.log.LogService; import java.lang.reflect.Field; @@ -67,8 +67,9 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { LogEntity logEntity = this.productLoEntity(declaredAnnotation, joinPoint); logService.addLog(logEntity); logEntity.setEndTime(new Timestamp(System.currentTimeMillis())); + Object proceed = null; try { - Object proceed = joinPoint.proceed(); + proceed = joinPoint.proceed(); logEntity.setStatus(2); logEntity.setResultContent(Objects.isNull(proceed) ? "" : proceed.toString()); return proceed; @@ -76,6 +77,7 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { logEntity.setStatus(3); throw new RuntimeException(e); } finally { + logEntity.setResultContent(proceed.toString()); logService.updateLog(logEntity); } @@ -94,7 +96,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j logEntity.setClusterId(opClusterPhyId); logEntity.setDescription(model.toString()); logEntity.setOperationType(declaredAnnotation.OprType()); - logEntity.setOperationTarget(declaredAnnotation.OprTarget()); + logEntity.setTargetType(declaredAnnotation.OprTarget()); logEntity.setStatus(1); logEntity.setCreateTime(new Timestamp(System.currentTimeMillis())); return logEntity; 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 2a2ae8e7..2c333cc2 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 @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.mapper.group; -import org.apache.eventmesh.dashboard.console.entity.GroupEntity; +import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; @@ -36,8 +36,7 @@ public interface OprGroupMapper { @Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)" + "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) " - + "on duplicate key update is_delete=0" - ) + + "on duplicate key update is_delete=0") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") void addGroup(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 ff58ef07..43bc7102 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 @@ -18,7 +18,7 @@ package org.apache.eventmesh.dashboard.console.mapper.groupmember; -import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity; +import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; @@ -39,24 +39,24 @@ public interface OprGroupMemberMapper { @Select("select * from group_member where cluster_id=#{clusterId} and is_delete=0") List getGroupByClusterId(GroupMemberEntity groupMemberEntity); - @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user)" - + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser})" + @Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user,state)" + + " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})" + "on duplicate key update is_delete=0") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity); + void addGroupMember(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where id=#{id}") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") - GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity); + void updateGroupMember(GroupMemberEntity groupMemberEntity); @Delete("update group_member set is_delete=1 where id=#{id} ") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity); - @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName}") + @Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName} and is_delete=0") GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity); - @Select("select * from group_member where id=#{id}") + @Select("select * from group_member where id=#{id} and is_delete=0") GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity); @Select("") List selectAllMemberByDynamic(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where topic_name=#{topicName}") - GroupMemberEntity updateMemberByTopic(GroupMemberEntity groupMemberEntity); + void updateMemberByTopic(GroupMemberEntity groupMemberEntity); } \ No newline at end of file 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 240f85cd..d6c96f72 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 @@ -17,7 +17,7 @@ package org.apache.eventmesh.dashboard.console.mapper.log; -import org.apache.eventmesh.dashboard.console.entity.LogEntity; +import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; @@ -36,22 +36,25 @@ public interface OprLogMapper { @Select("") + + "" + + "and cluster_id=#{clusterId} " + + "" + + "and is_delete=0" + + "" + + "") List getLogList(LogEntity logEntity); - @Insert("insert into operation_log ( cluster_id, operation_type,operation_target, description,operation_user)" - + "VALUE (#{clusterId},#{operationType},#{operationTarget},#{description},#{operationUser})") + @Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)" + + "VALUE (#{clusterId},#{operationType},#{targetType},#{description},#{operationUser},#{resultContent})") @SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class) Long addLog(LogEntity logEntity); - @Update("update operation_log set status=#{status} where id=#{id}") + @Update("update operation_log set status=#{status} ,result_content=#{resultContent} where id=#{id}") Integer updateLog(LogEntity logEntity); } 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 b56b815b..146a60d8 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 @@ -18,11 +18,12 @@ package org.apache.eventmesh.dashboard.console.mapper.topic; -import org.apache.eventmesh.dashboard.console.entity.TopicEntity; +import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; @@ -38,25 +39,28 @@ public interface TopicMapper { @Select("") - List getTopicListByClusterId(TopicEntity topicEntity); + List getTopicListByDynamic(TopicEntity topicEntity); @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " - + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})") - TopicEntity addTopic(TopicEntity topicEntity); + + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})" + + "on duplicate key update is_delete = 0") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") + void addTopic(TopicEntity topicEntity); @Update("update topic set type=#{type},description=#{description} where id=#{id}") - TopicEntity updateTopic(TopicEntity topicEntity); + void updateTopic(TopicEntity topicEntity); @Delete("update `topic` set is_delete=1 where id=#{id}") - TopicEntity deleteTopic(TopicEntity topicEntity); + void deleteTopic(TopicEntity topicEntity); @Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}") TopicEntity selectTopicByUnique(TopicEntity topicEntity); From 92b2953cbcf79a942c24aaee248de734ba459546 Mon Sep 17 00:00:00 2001 From: zzx <142965157+zzxxiansheng@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:39:53 +0800 Subject: [PATCH 11/19] Update and rename EventmeshConsoleApplication.java to EventMeshDashboardApplication.java --- ...nsoleApplication.java => EventMeshDashboardApplication.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/{EventmeshConsoleApplication.java => EventMeshDashboardApplication.java} (97%) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java similarity index 97% rename from eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java rename to eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java index ffcfa646..b7e6cb7c 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventmeshConsoleApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java @@ -26,7 +26,7 @@ @Slf4j @SpringBootApplication @EnableTransactionManagement -public class EventmeshConsoleApplication { +public class EventMeshDashboardApplication { public static void main(String[] args) { try { From 6dcb360122e46739b20c72ad091255fb79ed2685 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 17:48:25 +0800 Subject: [PATCH 12/19] rename this starter class file to EventMeshDashboardApplication --- .../dashboard/console/EventMeshDashboardApplication.java | 4 ++-- .../eventmesh/dashboard/console/unit/group/TestGroupDao.java | 5 +++-- .../console/unit/groupmember/testGroupMemberDao.java | 4 ++-- .../eventmesh/dashboard/console/unit/topic/testTopicDao.java | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java index b7e6cb7c..117dd062 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/EventMeshDashboardApplication.java @@ -30,8 +30,8 @@ public class EventMeshDashboardApplication { public static void main(String[] args) { try { - SpringApplication.run(EventmeshConsoleApplication.class, args); - log.info("{} Successfully booted.", EventmeshConsoleApplication.class.getSimpleName()); + SpringApplication.run(EventMeshDashboardApplication.class, args); + log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName()); } catch (Exception e) { log.error(e.getMessage(), e); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java index e1276e8e..abc33d66 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java @@ -1,6 +1,7 @@ package org.apache.eventmesh.dashboard.console.unit.group; -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; + import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.eventmesh.dashboard.console.mapper.group.OprGroupMapper; @@ -15,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) +@SpringBootTest(classes = EventMeshDashboardApplication.class) public class TestGroupDao { @Autowired diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java index 3a57bcee..f5d3451e 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java @@ -1,6 +1,6 @@ package org.apache.eventmesh.dashboard.console.unit.groupmember; -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity; import org.apache.eventmesh.dashboard.console.mapper.groupmember.OprGroupMemberMapper; @@ -15,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) +@SpringBootTest(classes = EventMeshDashboardApplication.class) public class testGroupMemberDao { @Autowired diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java index b60da0d4..6b1c962a 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java @@ -1,6 +1,6 @@ package org.apache.eventmesh.dashboard.console.unit.topic; -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity; import org.apache.eventmesh.dashboard.console.mapper.topic.TopicMapper; @@ -15,7 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) +@SpringBootTest(classes = EventMeshDashboardApplication.class) public class testTopicDao { @Autowired From 7f5bf0d5d6040f9a1ee6612f749a152a5feb6463 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 17:51:30 +0800 Subject: [PATCH 13/19] rename this starter class file to EventMeshDashboardApplication --- .../eventmesh/dashboard/console/linkage/log/TestOprLog.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java index 604e8c86..d5b7c521 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -1,6 +1,6 @@ package org.apache.eventmesh.dashboard.console.linkage.log; -import org.apache.eventmesh.dashboard.console.EventmeshConsoleApplication; +import org.apache.eventmesh.dashboard.console.EventMeshDashboardApplication; import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity; import org.apache.eventmesh.dashboard.console.entity.log.LogEntity; import org.apache.eventmesh.dashboard.console.service.group.GroupService; @@ -16,7 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = EventmeshConsoleApplication.class) +@SpringBootTest(classes = EventMeshDashboardApplication.class) public class TestOprLog { @Autowired From 7f2e85b212e841bda91f2bbd98cd0c5f69a42ecf Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 18:01:49 +0800 Subject: [PATCH 14/19] change some resource file --- .../src/main/resources/application-dev.yml | 3 +++ ...TestGroupDao.java => TestGroupMapper.java} | 18 +++++++-------- ...berDao.java => testGroupMemberMapper.java} | 22 +++++++++---------- ...testTopicDao.java => testTopicMapper.java} | 22 +++++++++---------- 4 files changed, 34 insertions(+), 31 deletions(-) rename eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/{TestGroupDao.java => TestGroupMapper.java} (86%) rename eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/{testGroupMemberDao.java => testGroupMemberMapper.java} (86%) rename eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/{testTopicDao.java => testTopicMapper.java} (85%) diff --git a/eventmesh-dashboard-console/src/main/resources/application-dev.yml b/eventmesh-dashboard-console/src/main/resources/application-dev.yml index 00724de5..0ff18a15 100644 --- a/eventmesh-dashboard-console/src/main/resources/application-dev.yml +++ b/eventmesh-dashboard-console/src/main/resources/application-dev.yml @@ -44,6 +44,9 @@ spring: test-while-idle: true min-evictable-idle-time-millis: 300000 +mybatis: + type-aliases-package: org.apache.eventmesh.dashboard.console.entity + # cron job config, use cron expression cron: #health check job diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java similarity index 86% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java index abc33d66..ca4bf9d5 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java @@ -17,16 +17,16 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class TestGroupDao { +public class TestGroupMapper { @Autowired - private OprGroupMapper groupDao; + private OprGroupMapper groupMapper; public List insertGroupData(String name) { List groupEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { GroupEntity groupEntity = new GroupEntity(null, (long) i, name, 0, null, 1, "OK", null, null); - groupDao.addGroup(groupEntity); + groupMapper.addGroup(groupEntity); groupEntities.add(groupEntity); } return groupEntities; @@ -35,7 +35,7 @@ public List insertGroupData(String name) { public List getRemovedTimeList(String name) { GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(name); - List groupEntities = groupDao.selectGroupByDynamic(groupEntity); + List groupEntities = groupMapper.selectGroupByDynamic(groupEntity); for (GroupEntity groupEntity1 : groupEntities) { groupEntity1.setCreateTime(null); groupEntity1.setUpdateTime(null); @@ -48,7 +48,7 @@ public void test_addGroup() { List groupEntities = this.insertGroupData("addGroup"); GroupEntity groupEntity = new GroupEntity(); groupEntity.setName("addGroup"); - List groupEntities1 = groupDao.selectGroupByDynamic(groupEntity); + List groupEntities1 = groupMapper.selectGroupByDynamic(groupEntity); Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup")); } @@ -60,7 +60,7 @@ public void test_updateGroupById() { groupEntity.setMembers("1,"); groupEntity.setState("fail"); groupEntity.setMemberCount(1); - groupDao.updateGroup(groupEntity); + groupMapper.updateGroup(groupEntity); Assert.assertEquals(groupEntities, this.getRemovedTimeList("updateById2")); } @@ -68,7 +68,7 @@ public void test_updateGroupById() { public void test_deleteGroupById() { List groupEntities = this.insertGroupData("deleteById"); GroupEntity groupEntity = groupEntities.get(9); - groupDao.deleteGroup(groupEntity); + groupMapper.deleteGroup(groupEntity); groupEntities.remove(9); Assert.assertEquals(groupEntities, this.getRemovedTimeList("deleteById")); } @@ -76,7 +76,7 @@ public void test_deleteGroupById() { @Test public void test_selectGroupById() { List groupEntities = this.insertGroupData("selectById"); - GroupEntity groupEntity = groupDao.selectGroupById(groupEntities.get(0)); + GroupEntity groupEntity = groupMapper.selectGroupById(groupEntities.get(0)); groupEntity.setCreateTime(null); groupEntity.setUpdateTime(null); Assert.assertEquals(groupEntities.get(0), groupEntity); @@ -88,7 +88,7 @@ public void test_selectGroupByClusterId() { GroupEntity groupEntity1 = new GroupEntity(); groupEntity1.setClusterId(groupEntities.get(0).getClusterId()); groupEntity1.setName(groupEntities.get(0).getName()); - GroupEntity groupEntity = groupDao.selectGroupByUnique(groupEntity1); + GroupEntity groupEntity = groupMapper.selectGroupByUnique(groupEntity1); groupEntity.setCreateTime(null); groupEntity.setUpdateTime(null); Assert.assertEquals(groupEntities.get(0), groupEntity); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java similarity index 86% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java index f5d3451e..2a02f997 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java @@ -16,16 +16,16 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class testGroupMemberDao { +public class testGroupMemberMapper { @Autowired - OprGroupMemberMapper groupMemberDao; + OprGroupMemberMapper groupMemberMapper; public List insertGroupData(String topicName, String groupName) { List groupMemberEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(null, (long) i, topicName, groupName, "admin", "active", null, null); - groupMemberDao.addGroupMember(groupMemberEntity); + groupMemberMapper.addGroupMember(groupMemberEntity); groupMemberEntities.add(groupMemberEntity); } return groupMemberEntities; @@ -35,7 +35,7 @@ public List getRemovedTimeList(String topicName, String group GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicName); groupMemberEntity.setGroupName(groupName); - List groupEntities = groupMemberDao.selectAllMemberByDynamic(groupMemberEntity); + List groupEntities = groupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); for (GroupMemberEntity groupEntity1 : groupEntities) { groupEntity1.setCreateTime(null); groupEntity1.setUpdateTime(null); @@ -54,7 +54,7 @@ public void test_getGroupMemberByClusterId() { List add1 = this.insertGroupData("getByCluster", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setClusterId(add1.get(1).getClusterId()); - List groupByClusterId = groupMemberDao.getGroupByClusterId(groupMemberEntity); + List groupByClusterId = groupMemberMapper.getGroupByClusterId(groupMemberEntity); GroupMemberEntity groupMemberEntity1 = groupByClusterId.get(0); groupMemberEntity1.setCreateTime(null); groupMemberEntity1.setUpdateTime(null); @@ -67,7 +67,7 @@ public void test_deleteGroupMemberById() { List add1 = this.insertGroupData("getById", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setId(add1.get(2).getId()); - GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(groupMemberEntity); groupMemberEntity1.setUpdateTime(null); groupMemberEntity1.setCreateTime(null); Assert.assertEquals(groupMemberEntity1, add1.get(2)); @@ -80,8 +80,8 @@ public void test_updateGroupMemberById() { add1.get(1).setState("fail1"); groupMemberEntity.setState("fail1"); groupMemberEntity.setId(add1.get(1).getId()); - groupMemberDao.updateGroupMember(groupMemberEntity); - GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(add1.get(1)); + groupMemberMapper.updateGroupMember(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(add1.get(1)); groupMemberEntity1.setUpdateTime(null); groupMemberEntity1.setCreateTime(null); Assert.assertEquals(groupMemberEntity1, add1.get(1)); @@ -94,7 +94,7 @@ public void test_selectGroupMemberByUnique() { groupMemberEntity.setClusterId(groupMemberEntities.get(1).getClusterId()); groupMemberEntity.setTopicName(groupMemberEntities.get(1).getTopicName()); groupMemberEntity.setGroupName(groupMemberEntities.get(1).getGroupName()); - GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberByUnique(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberByUnique(groupMemberEntity); groupMemberEntity1.setUpdateTime(null); groupMemberEntity1.setCreateTime(null); Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(1)); @@ -123,7 +123,7 @@ public void test_updateGroupMemberByTopic() { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setState("fail2"); groupMemberEntity.setTopicName("updateByTopic1"); - groupMemberDao.updateMemberByTopic(groupMemberEntity); + groupMemberMapper.updateMemberByTopic(groupMemberEntity); Assert.assertEquals(this.getRemovedTimeList("updateByTopic1", null), groupMemberEntities); } @@ -132,7 +132,7 @@ public void test_selectGroupMemberById() { List groupMemberEntities = this.insertGroupData("updateById1", "groupMember2"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setId(groupMemberEntities.get(5).getId()); - GroupMemberEntity groupMemberEntity1 = groupMemberDao.selectGroupMemberById(groupMemberEntity); + GroupMemberEntity groupMemberEntity1 = groupMemberMapper.selectGroupMemberById(groupMemberEntity); groupMemberEntity1.setCreateTime(null); groupMemberEntity1.setUpdateTime(null); Assert.assertEquals(groupMemberEntity1, groupMemberEntities.get(5)); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java similarity index 85% rename from eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java rename to eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java index 6b1c962a..1fdc01e8 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicDao.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java @@ -16,16 +16,16 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes = EventMeshDashboardApplication.class) -public class testTopicDao { +public class testTopicMapper { @Autowired - private TopicMapper topicDao; + private TopicMapper topicMapper; public List insertGroupData(String topicName) { List topicEntities = new ArrayList<>(); for (int i = 0; i < 10; i++) { TopicEntity topicEntity = new TopicEntity(null, (long) i, topicName, "10", "10", 100L, 1, "testTopic", null, null); - topicDao.addTopic(topicEntity); + topicMapper.addTopic(topicEntity); topicEntities.add(topicEntity); } return topicEntities; @@ -35,7 +35,7 @@ public List getRemovedTimeList(String topicName, Long clusterId) { TopicEntity topicEntity = new TopicEntity(); topicEntity.setTopicName(topicName); topicEntity.setClusterId(clusterId); - List topicEntities = topicDao.getTopicListByDynamic(topicEntity); + List topicEntities = topicMapper.getTopicListByDynamic(topicEntity); for (TopicEntity topic : topicEntities) { topic.setCreateTime(null); topic.setUpdateTime(null); @@ -48,7 +48,7 @@ public void test_selectTopicByClusterId() { List topicEntities = this.insertGroupData("SelectById111"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setClusterId(topicEntities.get(9).getClusterId()); - List topicEntity1 = topicDao.getTopicListByDynamic(topicEntity); + List topicEntity1 = topicMapper.getTopicListByDynamic(topicEntity); topicEntity1.get(0).setCreateTime(null); topicEntity1.get(0).setUpdateTime(null); Assert.assertEquals(topicEntity1.get(0), topicEntities.get(9)); @@ -71,8 +71,8 @@ public void test_UpdateTopic() { topicEntity.setDescription("updateTest1"); topicEntity.setType(-1); topicEntity.setId(topicEntities.get(5).getId()); - topicDao.updateTopic(topicEntity); - TopicEntity topicEntity1 = topicDao.selectTopicById(topicEntity); + topicMapper.updateTopic(topicEntity); + TopicEntity topicEntity1 = topicMapper.selectTopicById(topicEntity); topicEntity1.setUpdateTime(null); topicEntity1.setCreateTime(null); Assert.assertEquals(topicEntity1, topicEntities.get(5)); @@ -85,8 +85,8 @@ public void test_DeleteTopic() { topicEntity.setId(topicEntities.get(5).getId()); topicEntity.setClusterId(topicEntities.get(5).getClusterId()); topicEntity.setTopicName("update72"); - topicDao.deleteTopic(topicEntity); - List topicEntity1 = topicDao.getTopicListByDynamic(topicEntity); + topicMapper.deleteTopic(topicEntity); + List topicEntity1 = topicMapper.getTopicListByDynamic(topicEntity); Assert.assertEquals(true, topicEntity1.isEmpty()); } @@ -96,7 +96,7 @@ public void test_selectTopicByUnique() { TopicEntity topicEntity = new TopicEntity(); topicEntity.setTopicName("unique11"); topicEntity.setClusterId(topicEntities.get(1).getClusterId()); - TopicEntity topicEntity1 = topicDao.selectTopicByUnique(topicEntity); + TopicEntity topicEntity1 = topicMapper.selectTopicByUnique(topicEntity); topicEntity1.setUpdateTime(null); topicEntity1.setCreateTime(null); Assert.assertEquals(topicEntity1, topicEntities.get(1)); @@ -107,7 +107,7 @@ public void test_selectTopicById() { List topicEntities = this.insertGroupData("id1"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setId(topicEntities.get(2).getId()); - TopicEntity topicEntity1 = topicDao.selectTopicById(topicEntity); + TopicEntity topicEntity1 = topicMapper.selectTopicById(topicEntity); topicEntity1.setCreateTime(null); topicEntity1.setUpdateTime(null); Assert.assertEquals(topicEntity1, topicEntities.get(2)); From b9718ed5c45bdcbf186059525a71b6a4232e06b0 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 22:17:50 +0800 Subject: [PATCH 15/19] improve name --- .../dashboard/console/log/OprLog.java | 6 +++--- .../console/mapper/group/OprGroupMapper.java | 2 +- .../groupmember/OprGroupMemberMapper.java | 2 +- .../console/mapper/topic/TopicMapper.java | 6 +++--- .../console/service/group/GroupService.java | 4 ++-- .../service/group/GroupServiceImpl.java | 6 +++--- .../groupmember/GroupMemberServiceImp.java | 4 ++-- .../console/service/topic/TopicService.java | 4 ++-- .../service/topic/TopicServiceImpl.java | 6 +++--- .../console/linkage/log/TestOprLog.java | 4 ++-- .../console/unit/group/TestGroupMapper.java | 16 +++++++-------- .../groupmember/testGroupMemberMapper.java | 20 +++++++++---------- .../console/unit/topic/testTopicMapper.java | 18 ++++++++--------- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java index 11762d24..9df7e237 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/log/OprLog.java @@ -71,13 +71,13 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable { try { proceed = joinPoint.proceed(); logEntity.setStatus(2); - logEntity.setResultContent(Objects.isNull(proceed) ? "" : proceed.toString()); + logEntity.setResult(Objects.isNull(proceed) ? "" : proceed.toString()); return proceed; } catch (Throwable e) { logEntity.setStatus(3); throw new RuntimeException(e); } finally { - logEntity.setResultContent(proceed.toString()); + logEntity.setResult(proceed.toString()); logService.updateLog(logEntity); } @@ -94,7 +94,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j Long opClusterPhyId = (Long) clusterPhyId.get(model); //The clusterId is obtained from the parameter object, and the operation is described as the object itself logEntity.setClusterId(opClusterPhyId); - logEntity.setDescription(model.toString()); + logEntity.setContent(model.toString()); logEntity.setOperationType(declaredAnnotation.OprType()); logEntity.setTargetType(declaredAnnotation.OprTarget()); logEntity.setStatus(1); 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 2c333cc2..f1a91ede 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 @@ -67,7 +67,7 @@ public interface OprGroupMapper { + "and is_delete=0" + "" + "") - List selectGroupByDynamic(GroupEntity groupEntity); + 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 43bc7102..3179effc 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 @@ -74,7 +74,7 @@ public interface OprGroupMemberMapper { + "" + "and is_delete=0" + "") - List selectAllMemberByDynamic(GroupMemberEntity groupMemberEntity); + List selectMember(GroupMemberEntity groupMemberEntity); @Update("update group_member set state=#{state} where topic_name=#{topicName}") void updateMemberByTopic(GroupMemberEntity groupMemberEntity); 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 146a60d8..0f7d7813 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,8 +35,8 @@ @Mapper public interface TopicMapper { - - @Select("") - List getTopicListByDynamic(TopicEntity topicEntity); + List getTopicList(TopicEntity topicEntity); @Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) " + "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})" diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java index 953b582b..e5a80c56 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupService.java @@ -39,7 +39,7 @@ public interface GroupService { GroupEntity selectGroup(GroupEntity groupEntity); - Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity); + Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity); - Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity); + Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java index b849cac7..3647a5a6 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/group/GroupServiceImpl.java @@ -41,7 +41,7 @@ public class GroupServiceImpl implements GroupService { @EmLog(OprType = "search", OprTarget = "Group") @Override public List getGroupByClusterId(GroupEntity groupEntity) { - return oprGroupMapper.selectGroupByDynamic(groupEntity); + return oprGroupMapper.selectGroup(groupEntity); } @@ -68,7 +68,7 @@ public GroupEntity selectGroup(GroupEntity groupEntity) { } @Override - public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) { + public Integer insertMemberToGroup(GroupMemberEntity groupMemberEntity) { groupMemberService.addGroupMember(groupMemberEntity); GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(groupMemberEntity.getGroupName()); @@ -85,7 +85,7 @@ public Integer insertMemberToGroup_plus(GroupMemberEntity groupMemberEntity) { } @Override - public Integer deleteMemberFromGroup_plus(GroupMemberEntity groupMemberEntity) { + public Integer deleteMemberFromGroup(GroupMemberEntity groupMemberEntity) { groupMemberService.deleteGroupMember(groupMemberEntity); GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(groupMemberEntity.getGroupName()); diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java index f9815471..d50173e2 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/groupmember/GroupMemberServiceImp.java @@ -66,12 +66,12 @@ public List selectGroupMemberByGroup(GroupEntity groupEntity) groupMemberEntity.setGroupName(groupEntity.getName()); groupMemberEntity.setClusterId(groupEntity.getClusterId()); //Obtain a member who meets the conditions of a group - return oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); + return oprGroupMemberMapper.selectMember(groupMemberEntity); } @Override public List selectAllMemberByTopic(GroupMemberEntity groupMemberEntity) { - List groupMemberEntities = oprGroupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); + List groupMemberEntities = oprGroupMemberMapper.selectMember(groupMemberEntity); return groupMemberEntities; } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java index 86abdb83..95c8a32b 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicService.java @@ -31,11 +31,11 @@ public interface TopicService { void updateTopic(TopicEntity topicEntity); - void deleteTopic(TopicEntity topicEntity); + void deleteTopicById(TopicEntity topicEntity); TopicEntity selectTopicById(TopicEntity topicEntity); TopicEntity selectTopicByUnique(TopicEntity topicEntity); - void deleteTopic_plus(TopicEntity topicEntity); + void deleteTopic(TopicEntity topicEntity); } diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java index a4c1c11d..aa42e7ba 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/service/topic/TopicServiceImpl.java @@ -39,7 +39,7 @@ public class TopicServiceImpl implements TopicService { @Override public List getTopicList(TopicEntity topicEntity) { - return topicMapper.getTopicListByDynamic(topicEntity); + return topicMapper.getTopicList(topicEntity); } @Override @@ -57,7 +57,7 @@ public void updateTopic(TopicEntity topicEntity) { } @Override - public void deleteTopic(TopicEntity topicEntity) { + public void deleteTopicById(TopicEntity topicEntity) { topicMapper.deleteTopic(topicEntity); } @@ -72,7 +72,7 @@ public TopicEntity selectTopicByUnique(TopicEntity topicEntity) { } @Override - public void deleteTopic_plus(TopicEntity topicEntity) { + public void deleteTopic(TopicEntity topicEntity) { GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicEntity.getTopicName()); groupMemberEntity.setState("empty"); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java index d5b7c521..afaf8d8c 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/linkage/log/TestOprLog.java @@ -26,11 +26,11 @@ public class TestOprLog { private LogService logService; @Test - public void test_groupService_OprLog() { + public void testGroupServiceOprLog() { GroupEntity groupEntity = new GroupEntity(null, 1L, "logTest", 0, null, 1, "OK", null, null); GroupEntity groupEntity1 = groupService.addGroup(groupEntity); LogEntity logEntity = new LogEntity(null, 1L, "add", "Group", 2, groupEntity1.toString(), null, null, null, null); - logEntity.setResultContent(groupEntity.toString()); + logEntity.setResult(groupEntity.toString()); logEntity.setId(groupEntity1.getId()); List logListByCluster = logService.getLogListByCluster(logEntity); logListByCluster.get(0).setId(null); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java index ca4bf9d5..88dd3bce 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java @@ -35,7 +35,7 @@ public List insertGroupData(String name) { public List getRemovedTimeList(String name) { GroupEntity groupEntity = new GroupEntity(); groupEntity.setName(name); - List groupEntities = groupMapper.selectGroupByDynamic(groupEntity); + List groupEntities = groupMapper.selectGroup(groupEntity); for (GroupEntity groupEntity1 : groupEntities) { groupEntity1.setCreateTime(null); groupEntity1.setUpdateTime(null); @@ -44,16 +44,16 @@ public List getRemovedTimeList(String name) { } @Test - public void test_addGroup() { + public void testAddGroup() { List groupEntities = this.insertGroupData("addGroup"); GroupEntity groupEntity = new GroupEntity(); groupEntity.setName("addGroup"); - List groupEntities1 = groupMapper.selectGroupByDynamic(groupEntity); + List groupEntities1 = groupMapper.selectGroup(groupEntity); Assert.assertEquals(groupEntities, this.getRemovedTimeList("addGroup")); } @Test - public void test_updateGroupById() { + public void testUpdateGroupById() { List groupEntities = this.insertGroupData("updateById2"); GroupEntity groupEntity = groupEntities.get(9); groupEntity.setType(3); @@ -65,7 +65,7 @@ public void test_updateGroupById() { } @Test - public void test_deleteGroupById() { + public void testDeleteGroupById() { List groupEntities = this.insertGroupData("deleteById"); GroupEntity groupEntity = groupEntities.get(9); groupMapper.deleteGroup(groupEntity); @@ -74,7 +74,7 @@ public void test_deleteGroupById() { } @Test - public void test_selectGroupById() { + public void testSelectGroupById() { List groupEntities = this.insertGroupData("selectById"); GroupEntity groupEntity = groupMapper.selectGroupById(groupEntities.get(0)); groupEntity.setCreateTime(null); @@ -83,7 +83,7 @@ public void test_selectGroupById() { } @Test - public void test_selectGroupByClusterId() { + public void testSelectGroupByClusterId() { List groupEntities = this.insertGroupData("selectByUnique"); GroupEntity groupEntity1 = new GroupEntity(); groupEntity1.setClusterId(groupEntities.get(0).getClusterId()); @@ -95,7 +95,7 @@ public void test_selectGroupByClusterId() { } @Test - public void test_selectGroupByDynamic() { + public void testSelectGroupByDynamic() { List groupEntities = this.insertGroupData("selectByDynamic1"); Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic1")); } diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java index 2a02f997..d3a20a0f 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/groupmember/testGroupMemberMapper.java @@ -35,7 +35,7 @@ public List getRemovedTimeList(String topicName, String group GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setTopicName(topicName); groupMemberEntity.setGroupName(groupName); - List groupEntities = groupMemberMapper.selectAllMemberByDynamic(groupMemberEntity); + List groupEntities = groupMemberMapper.selectMember(groupMemberEntity); for (GroupMemberEntity groupEntity1 : groupEntities) { groupEntity1.setCreateTime(null); groupEntity1.setUpdateTime(null); @@ -44,13 +44,13 @@ public List getRemovedTimeList(String topicName, String group } @Test - public void test_addGroupMember() { + public void testAddGroupMember() { List add1 = this.insertGroupData("add1", "groupMember"); Assert.assertEquals(add1, this.getRemovedTimeList("add1", "groupMember")); } @Test - public void test_getGroupMemberByClusterId() { + public void testGetGroupMemberByClusterId() { List add1 = this.insertGroupData("getByCluster", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setClusterId(add1.get(1).getClusterId()); @@ -63,7 +63,7 @@ public void test_getGroupMemberByClusterId() { } @Test - public void test_deleteGroupMemberById() { + public void testDeleteGroupMemberById() { List add1 = this.insertGroupData("getById", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setId(add1.get(2).getId()); @@ -74,7 +74,7 @@ public void test_deleteGroupMemberById() { } @Test - public void test_updateGroupMemberById() { + public void testUpdateGroupMemberById() { List add1 = this.insertGroupData("updateById", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); add1.get(1).setState("fail1"); @@ -88,7 +88,7 @@ public void test_updateGroupMemberById() { } @Test - public void test_selectGroupMemberByUnique() { + public void testSelectGroupMemberByUnique() { List groupMemberEntities = this.insertGroupData("selectByUnique", "groupMember"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setClusterId(groupMemberEntities.get(1).getClusterId()); @@ -101,21 +101,21 @@ public void test_selectGroupMemberByUnique() { } @Test - public void test_selectGroupMemberByGroup() { + public void testSelectGroupMemberByGroup() { List groupMemberEntities = this.insertGroupData("selectByGroup1", "groupMember1"); List removedTimeList = this.getRemovedTimeList(null, "groupMember1"); Assert.assertEquals(groupMemberEntities, removedTimeList); } @Test - public void test_selectGroupMemberByTopic() { + public void testSelectGroupMemberByTopic() { List groupMemberEntities = this.insertGroupData("selectByTopic1", "groupMember2"); List removedTimeList = this.getRemovedTimeList("selectByTopic1", null); Assert.assertEquals(groupMemberEntities, removedTimeList); } @Test - public void test_updateGroupMemberByTopic() { + public void testUpdateGroupMemberByTopic() { List groupMemberEntities = this.insertGroupData("updateByTopic1", "groupMember2"); for (GroupMemberEntity groupMemberEntity : groupMemberEntities) { groupMemberEntity.setState("fail2"); @@ -128,7 +128,7 @@ public void test_updateGroupMemberByTopic() { } @Test - public void test_selectGroupMemberById() { + public void testSelectGroupMemberById() { List groupMemberEntities = this.insertGroupData("updateById1", "groupMember2"); GroupMemberEntity groupMemberEntity = new GroupMemberEntity(); groupMemberEntity.setId(groupMemberEntities.get(5).getId()); diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java index 1fdc01e8..7472792e 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/topic/testTopicMapper.java @@ -35,7 +35,7 @@ public List getRemovedTimeList(String topicName, Long clusterId) { TopicEntity topicEntity = new TopicEntity(); topicEntity.setTopicName(topicName); topicEntity.setClusterId(clusterId); - List topicEntities = topicMapper.getTopicListByDynamic(topicEntity); + List topicEntities = topicMapper.getTopicList(topicEntity); for (TopicEntity topic : topicEntities) { topic.setCreateTime(null); topic.setUpdateTime(null); @@ -44,11 +44,11 @@ public List getRemovedTimeList(String topicName, Long clusterId) { } @Test - public void test_selectTopicByClusterId() { + public void testSelectTopicByClusterId() { List topicEntities = this.insertGroupData("SelectById111"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setClusterId(topicEntities.get(9).getClusterId()); - List topicEntity1 = topicMapper.getTopicListByDynamic(topicEntity); + List topicEntity1 = topicMapper.getTopicList(topicEntity); topicEntity1.get(0).setCreateTime(null); topicEntity1.get(0).setUpdateTime(null); Assert.assertEquals(topicEntity1.get(0), topicEntities.get(9)); @@ -56,14 +56,14 @@ public void test_selectTopicByClusterId() { } @Test - public void test_addTopic() { + public void testAddTopic() { List topicEntities = this.insertGroupData("add111"); List add111 = this.getRemovedTimeList("add111", null); Assert.assertEquals(add111, topicEntities); } @Test - public void test_UpdateTopic() { + public void testUpdateTopic() { List topicEntities = this.insertGroupData("update2"); topicEntities.get(5).setDescription("updateTest1"); topicEntities.get(5).setType(-1); @@ -79,19 +79,19 @@ public void test_UpdateTopic() { } @Test - public void test_DeleteTopic() { + public void testDeleteTopic() { List topicEntities = this.insertGroupData("update72"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setId(topicEntities.get(5).getId()); topicEntity.setClusterId(topicEntities.get(5).getClusterId()); topicEntity.setTopicName("update72"); topicMapper.deleteTopic(topicEntity); - List topicEntity1 = topicMapper.getTopicListByDynamic(topicEntity); + List topicEntity1 = topicMapper.getTopicList(topicEntity); Assert.assertEquals(true, topicEntity1.isEmpty()); } @Test - public void test_selectTopicByUnique() { + public void testSelectTopicByUnique() { List topicEntities = this.insertGroupData("unique11"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setTopicName("unique11"); @@ -103,7 +103,7 @@ public void test_selectTopicByUnique() { } @Test - public void test_selectTopicById() { + public void testSelectTopicById() { List topicEntities = this.insertGroupData("id1"); TopicEntity topicEntity = new TopicEntity(); topicEntity.setId(topicEntities.get(2).getId()); From b4ab6875d139fa9b93b1f01a95de455356ceaa01 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 22:18:09 +0800 Subject: [PATCH 16/19] improve name --- .../eventmesh/dashboard/console/entity/log/LogEntity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java index 49e3c236..ac7c30aa 100644 --- a/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java +++ b/eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/log/LogEntity.java @@ -38,7 +38,7 @@ public class LogEntity { private Integer status; - private String description; + private String content; private Timestamp createTime; @@ -46,6 +46,6 @@ public class LogEntity { private String operationUser; - private String resultContent; + private String result; } From bff80be6e86a1a229a3595c7dc7ab1105b1f318f Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 22:37:32 +0800 Subject: [PATCH 17/19] Modify the fields of the synchronized log table --- .../src/main/resources/eventmesh-dashboard.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index 4699e7a6..ccba8e13 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -61,11 +61,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:失败', - `description` text COMMENT '备注信息', + `contain` text 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_content` text, + `result` text, `target_type` varchar(192) NOT NULL, `is_delete` int NOT NULL DEFAULT '0', PRIMARY KEY (`id`), From e5765d062ae2820c4ebcc6969b878ffe064f8c4a Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 23:38:47 +0800 Subject: [PATCH 18/19] improve name --- .../src/main/resources/eventmesh-dashboard.sql | 2 +- .../eventmesh/dashboard/console/unit/group/TestGroupMapper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql index ccba8e13..96cf1e3f 100644 --- a/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql +++ b/eventmesh-dashboard-console/src/main/resources/eventmesh-dashboard.sql @@ -61,7 +61,7 @@ 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:失败', - `contain` text COMMENT '备注信息', + `content` text COMMENT '备注信息', `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `end_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间', `operation_user` varchar(192) DEFAULT NULL, diff --git a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java index 88dd3bce..f247c3fb 100644 --- a/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java +++ b/eventmesh-dashboard-console/src/test/java/org/apache/eventmesh/dashboard/console/unit/group/TestGroupMapper.java @@ -95,7 +95,7 @@ public void testSelectGroupByClusterId() { } @Test - public void testSelectGroupByDynamic() { + public void testSelectGroup() { List groupEntities = this.insertGroupData("selectByDynamic1"); Assert.assertEquals(groupEntities, this.getRemovedTimeList("Dynamic1")); } From 390dd05b5d4454c222608f96b23fd06ec1ad1416 Mon Sep 17 00:00:00 2001 From: zzx <2651787250@qq.com> Date: Mon, 5 Feb 2024 23:40:05 +0800 Subject: [PATCH 19/19] improve name --- .../eventmesh/dashboard/console/mapper/topic/TopicMapper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 0f7d7813..8a396be6 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,8 +35,7 @@ @Mapper public interface TopicMapper { - @Select( - "