Skip to content

Commit

Permalink
[ISSUE #161] Canonical code (#162)
Browse files Browse the repository at this point in the history
* Changes to code specifications

* Resolve syntax errors

* Code Specification

* Code Specification

---------

Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com>
  • Loading branch information
zzxxiansheng and 周倬贤 authored Jun 16, 2024
1 parent d3ffcb5 commit 18bfad4
Show file tree
Hide file tree
Showing 82 changed files with 890 additions and 594 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

package org.apache.eventmesh.dashboard.console.controller;


import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity;
import org.apache.eventmesh.dashboard.console.entity.connector.ConnectorEntity;
import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.AddConnectionDTO;
import org.apache.eventmesh.dashboard.console.mapstruct.connection.ConnectionControllerMapper;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.CreateConnectionDTO;
import org.apache.eventmesh.dashboard.console.modle.dto.connection.GetConnectionListDTO;
import org.apache.eventmesh.dashboard.console.modle.vo.connection.ConnectionListVO;
Expand All @@ -32,9 +34,11 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cluster/connection")
public class ConnectionController {

@Autowired
Expand All @@ -46,41 +50,40 @@ public class ConnectionController {
* @param type
* @return
*/
@GetMapping("/cluster/connection/getConnectorBusinessType")
@GetMapping("/getConnectorBusinessType")
public List<String> getConnectorBusinessType(String type) {
return connectionDataService.getConnectorBusinessType(type);
}

@GetMapping("/cluster/connection/getConnectorConfigs")
@GetMapping("/getConnectorConfigs")
public List<ConfigEntity> getConnectorConfigsByClassAndVersion(String version, String classType) {
return connectionDataService.getConnectorConfigsByClassAndVersion(classType, version);
}


@GetMapping("/cluster/connection/showCreateConnectionMessage")
public AddConnectionDTO showCreateConnectionMessage() {
return new AddConnectionDTO();
@GetMapping("/showCreateConnectionMessage")
public AddConnectionEntity showCreateConnectionMessage() {
return new AddConnectionEntity();
}


@PostMapping("/cluster/connection/createConnection")
@PostMapping("/createConnection")
public String createConnection(@Validated @RequestBody CreateConnectionDTO createConnectionDTO) {
try {
connectionDataService.createConnection(createConnectionDTO);

connectionDataService.createConnection(ConnectionControllerMapper.INSTANCE.queryCreateEntityByConnection(createConnectionDTO));
} catch (Exception e) {
return e.getMessage();
}
return "success";
}


@PostMapping("/cluster/connection/getConnectionList")
@PostMapping("/getConnectionList")
public List<ConnectionListVO> getConnectionList(@Validated @RequestBody GetConnectionListDTO getConnectionListDTO) {
return connectionDataService.getConnectionToFrontByCluster(getConnectionListDTO.getClusterId(), getConnectionListDTO);
return connectionDataService.getConnectionToFrontByCluster(ConnectionControllerMapper.INSTANCE.queryEntityByConnection(getConnectionListDTO));
}

@GetMapping("/cluster/connection/getConnectorDetail")
@GetMapping("/getConnectorDetail")
public ConnectorEntity getConnectorDetail(Long connectorId) {
return connectionDataService.getConnectorById(connectorId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ public class ClusterController {
@Autowired
ClusterService clusterService;




@GetMapping("queryHomeClusterData")
public GetClusterBaseMessageVO queryHomeClusterData(@RequestBody @Validated ClusterIdDTO clusterIdDTO) {
return clusterService.getClusterBaseMessage(clusterIdDTO);
return clusterService.selectClusterBaseMessage(clusterIdDTO.getClusterId());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ClusterRelationshipController {

@PostMapping("addClusterRelationshipEntry")
public void addClusterRelationshipEntry(@RequestBody ClusterRelationshipEntity clusterRelationshipEntity) {
this.clusterRelationshipService.addClusterRelationshipEntry(clusterRelationshipEntity);
this.clusterRelationshipService.insertClusterRelationshipEntry(clusterRelationshipEntity);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class RuntimeController {
@PostMapping("/queryRuntimeListByClusterId")
public List<RuntimeEntity> queryRuntimeListByClusterId(@Validated @RequestBody ClusterIdDTO clusterIdDTO) {
List<RuntimeEntity> runtimeEntityList =
runtimeService.getRuntimeToFrontByClusterId(RuntimeControllerMapper.INSTANCE.queryRuntimeListByClusterId(clusterIdDTO));
runtimeService.selectRuntimeToFrontByClusterId(RuntimeControllerMapper.INSTANCE.queryRuntimeListByClusterId(clusterIdDTO));
runtimeEntityList.forEach(n -> {
n.setStatus(CheckResultCache.getINSTANCE().getLastHealthyCheckResult("runtime", n.getId()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.dashboard.console.controller.function;

import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity;
import org.apache.eventmesh.dashboard.console.mapstruct.config.ConfigControllerMapper;
import org.apache.eventmesh.dashboard.console.modle.dto.config.DetailConfigsVO;
import org.apache.eventmesh.dashboard.console.modle.dto.config.GetConfigsListDTO;
import org.apache.eventmesh.dashboard.console.modle.dto.config.UpdateConfigDTO;
Expand All @@ -31,32 +32,32 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cluster/config")
public class ConfigController {

@Autowired
private ConfigService configService;

@PostMapping("/cluster/config/updateConfigs")
@PostMapping("/updateConfigs")
public String updateConfigsByTypeAndId(@Validated @RequestBody UpdateConfigDTO updateConfigDTO) {
try {
configService.updateConfigsByInstanceId(updateConfigDTO.getUsername(), updateConfigDTO.getClusterId(), updateConfigDTO.getInstanceType(),
updateConfigDTO.getInstanceId(), updateConfigDTO.getChangeConfigDTOS());
updateConfigDTO.getInstanceId(), updateConfigDTO.getChangeConfigEntities());
} catch (Exception e) {
return e.getMessage();
}
return "success";
}


@PostMapping("/cluster/config/getInstanceDetailConfigs")
@PostMapping("/getInstanceDetailConfigs")
public List<DetailConfigsVO> getInstanceDetailConfigs(@Validated @RequestBody GetConfigsListDTO getConfigsListDTO) {
List<ConfigEntity> configEntityList = configService.selectToFront(getConfigsListDTO.getInstanceId(),
getConfigsListDTO.getInstanceType(), getConfigsListDTO);
Map<String, String> stringStringConcurrentHashMap = configService.selectDefaultConfig(getConfigsListDTO.getBusinessType(),
getConfigsListDTO.getInstanceId(), getConfigsListDTO.getInstanceType());
List<ConfigEntity> configEntityList = configService.selectToFront(ConfigControllerMapper.INSTANCE.queryEntityByConfig(getConfigsListDTO));
Map<String, String> stringStringConcurrentHashMap = configService.selectDefaultConfig(getConfigsListDTO.getBusinessType());
ArrayList<DetailConfigsVO> showDetailConfigsVOS = new ArrayList<>();
configEntityList.forEach(n -> {
DetailConfigsVO showDetailConfigsVO = new DetailConfigsVO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cluster/health")
public class HealthController {

@Autowired
HealthDataService healthDataService;

@GetMapping("/cluster/health/getHistoryLiveStatus")
@GetMapping("/getHistoryLiveStatus")
public List<HealthCheckResultEntity> getHistoryLiveStatusById(Integer type, Long instanceId, String startTime) {
return healthDataService.getInstanceLiveStatusHistory(type, instanceId, LocalDateTime.parse(startTime));
return healthDataService.selectInstanceLiveStatusHistory(type, instanceId, LocalDateTime.parse(startTime));
}

@GetMapping("/cluster/health/getInstanceLiveProportion")
@GetMapping("/getInstanceLiveProportion")
public InstanceLiveProportionVo getInstanceLiveProportion(Integer instanceType, Long theClusterId) {
return healthDataService.getInstanceLiveProportion(theClusterId, instanceType);
return healthDataService.selectInstanceLiveProportion(theClusterId, instanceType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.eventmesh.dashboard.console.controller.function;

import org.apache.eventmesh.dashboard.console.entity.function.LogEntity;
import org.apache.eventmesh.dashboard.console.mapstruct.log.LogControllerMapper;
import org.apache.eventmesh.dashboard.console.modle.dto.log.GetLogListDTO;
import org.apache.eventmesh.dashboard.console.service.function.LogService;

Expand All @@ -27,17 +28,19 @@
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/cluster/log")
public class LogController {

@Autowired
private LogService logService;

@PostMapping("/cluster/log/getList")
@PostMapping("/getList")
public List<LogEntity> getLogLIstToFront(@Validated @RequestBody GetLogListDTO getLogListDTO) {
return logService.getLogListByCluster(getLogListDTO);
return logService.selectLogListByCluster(LogControllerMapper.INSTANCE.queryEntityByLog(getLogListDTO));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class GroupController {

@PostMapping("queryGroupListByClusterId")
public List<GroupEntity> queryGroupListByClusterId(@RequestBody @Validated ClusterIdDTO clusterIdDTO) {
return groupService.getGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(clusterIdDTO));
return groupService.selectGroupByClusterId(GroupControllerMapper.INSTANCE.queryGroupListByClusterId(clusterIdDTO));
}

@PostMapping("deleteGroupById")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class TopicController {

@PostMapping("/queryTopicListByClusterId")
public List<TopicEntity> queryTopicListByClusterId(@Validated @RequestBody GetTopicListDTO getTopicListDTO) {
return topicService.getTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO));
return topicService.selectTopicListToFront(TopicControllerMapper.INSTANCE.queryTopicListByClusterId(getTopicListDTO));
}

@PostMapping("queryTopicListById ")
Expand All @@ -72,7 +72,7 @@ public void createTopic(@Validated @RequestBody CreateTopicDTO createTopicDTO) {
*/
@GetMapping("/cluster/topic/getTopicDetailGroups")
public List<TopicDetailGroupVO> getTopicDetailGroups(Long topicId) {
return topicService.getTopicDetailGroups(topicId);
return topicService.selectTopicDetailGroups(topicId);
}

}
Original file line number Diff line number Diff line change
@@ -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.entity;

import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectionEntity;
import org.apache.eventmesh.dashboard.console.entity.connection.AddConnectorConfigEntity;

import lombok.Data;

@Data
public class CreateConnectionEntity {

private Long clusterId;

private AddConnectionEntity addConnectionEntity;

private AddConnectorConfigEntity addConnectorConfigEntity;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
package org.apache.eventmesh.dashboard.console.entity;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class DefaultConfigKey {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.modle.dto.connection;
package org.apache.eventmesh.dashboard.console.entity.connection;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class AddConnectionDTO {
public class AddConnectionEntity {

private String sinkName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.console.modle.dto.connection;
package org.apache.eventmesh.dashboard.console.entity.connection;

import org.apache.eventmesh.dashboard.console.entity.function.ConfigEntity;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class AddConnectorConfigDTO {
public class AddConnectorConfigEntity {

private List<ConfigEntity> sinkConnectorConfigs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@

import io.swagger.v3.oas.annotations.media.Schema;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;


@Data
@EqualsAndHashCode(callSuper = true, exclude = "resultDesc")
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "HealthCheckResultEntity", description = "Health check result entity")
public class HealthCheckResultEntity extends BaseEntity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true, exclude = {"endTime", "operationUser", "result"})
public class LogEntity extends BaseEntity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ public void updateHealthCheckConfigs(DataServiceWrapper dataServiceWrapper) {
.host(store.getHost())
.port(store.getPort())
.build());
checkResultEntities.add(HealthCheckResultEntity.builder()
.clusterId(store.getClusterId())
.type(4)
.typeId(store.getId())
.state(4)
.resultDesc("initializing check client")
.build());
HealthCheckResultEntity healthCheckResultEntity = new HealthCheckResultEntity();
healthCheckResultEntity.setClusterId(store.getClusterId());
healthCheckResultEntity.setType(4);
healthCheckResultEntity.setTypeId(store.getId());
healthCheckResultEntity.setState(4);
healthCheckResultEntity.setResultDesc("initializing check client");
checkResultEntities.add(healthCheckResultEntity);
}

dataServiceWrapper.getHealthDataService().batchInsertNewCheckResult(checkResultEntities);
Expand Down
Loading

0 comments on commit 18bfad4

Please sign in to comment.