From 11d1668b942e93c3cf17e6216fc2ce964452fd1b Mon Sep 17 00:00:00 2001 From: "lambert@arch" Date: Sun, 21 Jan 2024 15:19:10 +0800 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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