Skip to content

Commit

Permalink
[ISSUE #57] Modify the field, synchronize the modification, and add t…
Browse files Browse the repository at this point in the history
…he mapper method (#58)

* refactor: add dependency of console module and move controllers into console module.

* fix: add logback config, fix application-dev.yml and move `</dependencyManagement>` to root `pom.xml` as pointed out in PR#19.

* FirstCommit

* remerge

* first improve

* second improve

* third improve

* fourth improve

* fourth improve

* fourth improve

* Update and rename EventmeshConsoleApplication.java to EventMeshDashboardApplication.java

* rename this starter class file to EventMeshDashboardApplication

* rename this starter class file to EventMeshDashboardApplication

* change some resource file

* improve name

* improve name

* Modify the fields of the synchronized log table

* improve name

* improve name

* config basic function and config ,runtime,store,cluster sql

* try to resolve build error

* Some changes in the specification

* something rename

* one sql update

* tag something to do

* The distinction between state and status is_delete fields is unified, and selectAll() and batchInsert() are added to all instance tables for subsequent data synchronization. Modification of some fields.

* Delete eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/ClusterEntity1.java

delete something no use

* Delete eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/meta/RuntimeEntity1.java

delete something no use

* improve something checkstyle error

* try to solve something sql test error

* try to resolve something test error

* try to resolve something test error

* something is_delete(error) change to status (#3)

Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com>

---------

Co-authored-by: lambert@arch <lambertrao@outlook.com>
Co-authored-by: 周倬贤 <14100340+zhou-zhuoxian@user.noreply.gitee.com>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent ac14afc commit a165e04
Show file tree
Hide file tree
Showing 49 changed files with 453 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.cluster;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ClusterEntity {
public class ClusterEntity extends BaseEntity {

private Long id;

Expand All @@ -50,7 +52,11 @@ public class ClusterEntity {

private Integer runState;

private Integer status;

private Timestamp createTime;

private Timestamp updateTime;

private Integer storeType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.config;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ConfigEntity {
public class ConfigEntity extends BaseEntity {

private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.group;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,8 @@
@NoArgsConstructor
@AllArgsConstructor
@Data
public class GroupEntity {
public class GroupEntity extends BaseEntity {

private Long id;

private Long clusterId;
Expand All @@ -45,6 +48,6 @@ public class GroupEntity {

private Timestamp updateTime;


private Integer status;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.groupmember;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,8 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GroupMemberEntity {
public class GroupMemberEntity extends BaseEntity {

private Long id;

private Long clusterId;
Expand All @@ -43,5 +46,5 @@ public class GroupMemberEntity {

private Timestamp updateTime;


private Integer status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class HealthCheckResultEntity extends BaseEntity {

private String resultDesc;

@Schema(description = "status of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time")
private Integer status;
@Schema(description = "state of a health check, 0: failed, 1: passed, 2: doing check, 3: out of time")
private Integer state;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.log;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LogEntity {
public class LogEntity extends BaseEntity {

private Long id;

Expand All @@ -36,7 +38,7 @@ public class LogEntity {

private String targetType;

private Integer status;
private Integer state;

private String content;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.runtime;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RuntimeEntity {
public class RuntimeEntity extends BaseEntity {

private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.eventmesh.dashboard.console.entity.storage;


import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -27,7 +29,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class StoreEntity {
public class StoreEntity extends BaseEntity {

private Long id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.eventmesh.dashboard.console.entity.topic;

import org.apache.eventmesh.dashboard.console.entity.base.BaseEntity;

import java.sql.Timestamp;

import lombok.AllArgsConstructor;
Expand All @@ -26,7 +28,8 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TopicEntity {
public class TopicEntity extends BaseEntity {

private Long id;

private Long clusterId;
Expand All @@ -47,4 +50,5 @@ public class TopicEntity {

private Timestamp updateTime;

private Integer status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void addToResultList(CheckResult result, ArrayList<HealthCheckResultEnti
newEntity.setType(HealthCheckType.toNumber(result.getConfig().getHealthCheckResourceType()));
newEntity.setTypeId(result.getConfig().getInstanceId());
newEntity.setResultDesc(result.getResultDesc());
newEntity.setStatus(result.getStatus().getNumber());
newEntity.setState(result.getStatus().getNumber());

resultList.add(newEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable {
Object proceed = null;
try {
proceed = joinPoint.proceed();
logEntity.setStatus(2);
logEntity.setState(2);
logEntity.setResult(Objects.isNull(proceed) ? "" : proceed.toString());
return proceed;
} catch (Throwable e) {
logEntity.setStatus(3);
logEntity.setState(3);
throw new RuntimeException(e);
} finally {
logEntity.setResult(proceed.toString());
Expand All @@ -97,7 +97,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j
logEntity.setContent(model.toString());
logEntity.setOperationType(declaredAnnotation.OprType());
logEntity.setTargetType(declaredAnnotation.OprTarget());
logEntity.setStatus(1);
logEntity.setState(1);
logEntity.setCreateTime(new Timestamp(System.currentTimeMillis()));
return logEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@

import java.util.List;


/**
* Mybatis Mapper for the table of client.
*/
@Mapper
public interface ClientMapper {

@Select("select * from client where status=1")
List<ClientEntity> selectAll();

@Select({
"<script>",
" INSERT INTO client (cluster_id, name, platform, language, pid, host, port, protocol, status,",
" config_ids, description) VALUES ",
" <foreach collection='list' item='c' index='index' separator=','>",
" (#{c.clusterId}, #{c.name}, #{c.platform},#{c.language}, #{c.pid}, #{c.host}, #{c.port}, #{c.protocol},",
" #{c.status}, #{c.configIds}, #{c.description})",
" </foreach>",
"</script>"})
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void batchInsert(List<ClientEntity> clientEntityList);

@Select("SELECT * FROM `client` WHERE `id` = #{id}")
ClientEntity selectById(ClientEntity clientEntity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,28 @@
@Mapper
public interface ClusterMapper {

@Select("SELECT * FROM cluster WHERE is_delete=0")
@Select("SELECT * FROM cluster WHERE status=1")
List<ClusterEntity> selectAllCluster();

@Select("SELECT * FROM cluster WHERE id=#{id} AND is_delete=0")
@Insert({
"<script>",
" INSERT INTO cluster (name, register_name_list, bootstrap_servers, eventmesh_version, client_properties, jmx_properties,",
"reg_properties, description, auth_type,run_state, store_type) VALUES ",
" <foreach collection='list' item='c' index='index' separator=','>",
" (#{c.name}, #{c.registerNameList}, #{c.bootstrapServers}, #{c.eventmeshVersion}, #{c.clientProperties}, #{c.jmxProperties}, ",
" #{c.regProperties}, #{c.description}, #{c.authType}, #{c.runState},#{c.storeType})",
" </foreach>",
"</script>"})
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void batchInsert(List<ClusterEntity> clusterEntities);

@Select("SELECT * FROM cluster WHERE id=#{id} AND status=1")
ClusterEntity selectClusterById(ClusterEntity cluster);

@Insert("INSERT INTO cluster (name, register_name_list, bootstrap_servers, eventmesh_version, client_properties, "
+ "jmx_properties, reg_properties, description, auth_type, run_state) VALUES (#{name},#{registerNameList},"
+ "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType},#{runState})")
+ "jmx_properties, reg_properties, description, auth_type, run_state,store_type) VALUES (#{name},#{registerNameList},"
+ "#{bootstrapServers},#{eventmeshVersion},#{clientProperties},#{jmxProperties},#{regProperties},#{description},#{authType},"
+ "#{runState},#{storeType})")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void addCluster(ClusterEntity cluster);

Expand All @@ -52,7 +65,7 @@ public interface ClusterMapper {
+ "register_name_list=#{registerNameList} WHERE id=#{id}")
void updateClusterById(ClusterEntity cluster);

@Delete("UPDATE cluster SET is_delete=1 WHERE id=#{id}")
@Delete("UPDATE cluster SET status=0 WHERE id=#{id}")
void deleteClusterById(ClusterEntity clusterEntity);

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,30 @@
@Mapper
public interface ConfigMapper {

@Insert("INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name,"
+ " config_value, start_version,eventmesh_version, description, edit,end_version,is_default,is_modify) VALUE "
@Select("SELECT * FROM config WHERE status=1")
List<ConfigEntity> selectAll();

@Insert({
"<script>",
" INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name, config_value, start_version,",
" eventmesh_version,end_version, diff_type, description, edit, is_default, is_modify) VALUES ",
" <foreach collection='list' item='c' index='index' separator=','>",
" (#{c.clusterId}, #{c.businessType}, #{c.instanceType}, #{c.instanceId},#{c.configName},",
" #{c.configValue}, #{c.startVersion}, #{c.eventmeshVersion},#{c.endVersion},#{c.diffType},#{c.description},",
" #{c.edit},#{c.isDefault},#{c.isModify})",
" </foreach>",
"</script>"})
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void batchInsert(List<ConfigEntity> configEntityList);

@Insert("INSERT INTO config (cluster_id, business_type, instance_type, instance_id, config_name, config_value, start_version, "
+ "status, is_default, end_version, diff_type, description, edit, is_modify, eventmesh_version) VALUE "
+ "(#{clusterId},#{businessType},#{instanceType},#{instanceId},#{configName},"
+ "#{configValue},#{startVersion},#{eventmeshVersion},#{description},#{edit},#{endVersion},#{isDefault},#{isModify})")
+ "#{configValue},#{startVersion},#{status},#{isDefault},#{endVersion},#{diffType},#{description},#{edit},#{isModify},#{eventmeshVersion})")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
Integer addConfig(ConfigEntity configEntity);

@Update("UPDATE config SET status=2 WHERE id=#{id}")
@Update("UPDATE config SET status=0 WHERE id=#{id}")
Integer deleteConfig(ConfigEntity configEntity);

@Update("UPDATE config SET config_value=#{configValue} WHERE status=1 AND edit=2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ public List<ConnectionEntity> selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan
"</script>"})
void batchEndConnectionById(List<ConnectionEntity> connectionEntityList);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
@Mapper
public interface ConnectorMapper {

@Select("SELECT * FROM connector WHERE status=1")
ConnectorEntity selectAll();

@Select("SELECT * FROM connector WHERE id = #{id}")
ConnectorEntity selectById(ConnectorEntity connectorEntity);

Expand Down
Loading

0 comments on commit a165e04

Please sign in to comment.