Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #30] modify mappers and add test #38

Merged
merged 5 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

services:
mysql:
image: mysql:8
image: mysql:8.0
env:
# The MySQL docker container requires these environment variables to be set, so we can create and migrate the test database.
MYSQL_DATABASE: eventmesh_dashboard_test
Expand Down
2 changes: 1 addition & 1 deletion eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>org.apache.eventmesh</groupId>
<artifactId>eventmesh-sdk-java</artifactId>
<version>1.9.0-release</version>
<version>1.10.0-release</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import lombok.Getter;

@AllArgsConstructor
public enum HealthCheckTypeEnum {
public enum HealthCheckType {
UNKNOWN(0, "unknown"),

CLUSTER(1, "cluster"),
Expand All @@ -38,7 +38,7 @@ public enum HealthCheckTypeEnum {
private final String name;

public static Integer toNumber(String name) {
for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) {
for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) {
if (healthCheckTypeEnum.name.equals(name)) {
return healthCheckTypeEnum.number;
}
Expand All @@ -47,7 +47,7 @@ public static Integer toNumber(String name) {
}

public static String toName(Integer number) {
for (HealthCheckTypeEnum healthCheckTypeEnum : HealthCheckTypeEnum.values()) {
for (HealthCheckType healthCheckTypeEnum : HealthCheckType.values()) {
if (healthCheckTypeEnum.number.equals(number)) {
return healthCheckTypeEnum.name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public interface ClientMapper {
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert(
"INSERT INTO `client` (`cluster_id`, `name`, `platform`,"
+ " `language`, `pid`, `host`, `port`, `protocol`,"
+ " `status`, `config_ids`, `description`) "
+ "`language`, `pid`, `host`, `port`, `protocol`,"
+ "`status`, `config_ids`, `description`) "
+ "VALUES (#{clusterId}, #{name}, #{platform},"
+ " #{language}, #{pid}, #{host}, #{port}, #{protocol},"
+ " #{status}, #{configIds}, #{description})")
+ "#{language}, #{pid}, #{host}, #{port}, #{protocol},"
+ "#{status}, #{configIds}, #{description})")
void insert(ClientEntity clientEntity);

@Update("UPDATE `client` SET status = 0, end_time = NOW() WHERE id = #{id}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,34 @@ public List<ConnectionEntity> selectByClusterIdSinkTypeAndSinkIdAndCreateTimeRan
@Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);

@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("INSERT INTO connection (cluster_id, source_type, source_id,"
+ " sink_type, sink_id, runtime_id, status, topic, group_id, description)"
@Insert("INSERT INTO connection (cluster_id, source_type, source_id," + " sink_type, sink_id, runtime_id, status, topic, group_id, description)"
+ " VALUES ( #{clusterId}, #{sourceType}, #{sourceId}, "
Pil0tXia marked this conversation as resolved.
Show resolved Hide resolved
+ " #{sinkType}, #{sinkId}, #{runtimeId}, #{status}, #{topic}, #{groupId}, #{description})")
void insert(ConnectionEntity connectionEntity);

@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("<script>"
+ "INSERT INTO connection (cluster_id, source_type, source_id,"
+ " sink_type, sink_id, runtime_id, status,"
+ " topic, group_id, description) VALUES "
+
"<foreach collection='list' item='connectionEntity' index='index' separator=','>"
+ "(#{connectionEntity.clusterId}, #{connectionEntity.sourceType}, #{connectionEntity.sourceId},"
+ " #{connectionEntity.sinkType}, #{connectionEntity.sinkId}, #{connectionEntity.runtimeId}, #{connectionEntity.status},"
+ " #{connectionEntity.topic}, #{connectionEntity.groupId}, #{connectionEntity.description})"
+ "</foreach>"
+ "</script>")
@Insert({
"<script>",
" INSERT INTO connection (cluster_id, source_type, source_id," + " sink_type, sink_id, runtime_id, status,",
" topic, group_id, description) VALUES ",
" <foreach collection='list' item='connectionEntity' index='index' separator=','>",
" (#{connectionEntity.clusterId}, #{connectionEntity.sourceType}, #{connectionEntity.sourceId},",
" #{connectionEntity.sinkType}, #{connectionEntity.sinkId}, #{connectionEntity.runtimeId}, #{connectionEntity.status},",
" #{connectionEntity.topic}, #{connectionEntity.groupId}, #{connectionEntity.description})",
" </foreach>",
"</script>"})
void batchInsert(List<ConnectionEntity> connectionEntityList);

@Update("UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{id}")
void endConnectionById(ConnectionEntity connectionEntity);

//batch end
@Update({
"<script><foreach collection='list' item='connectionEntity' index='index' separator=';'>",
"UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{connectionEntity.id}",
"</foreach></script>"})
"<script>",
" <foreach collection='list' item='connectionEntity' index='index' separator=';'>",
" UPDATE connection SET status = 1, end_time = NOW() WHERE id = #{connectionEntity.id}",
" </foreach>",
"</script>"})
void batchEndConnectionById(List<ConnectionEntity> connectionEntityList);

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public interface ConnectorMapper {
void insert(ConnectorEntity connectorEntity);

@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@Insert("<script>"
+ "INSERT INTO connector (cluster_id, name, class_name, type, status, pod_state, config_ids) VALUES "
+
"<foreach collection='list' item='connectorEntity' index='index' separator=','>"
+ "(#{connectorEntity.clusterId}, #{connectorEntity.name}, #{connectorEntity.className},"
+ " #{connectorEntity.type}, #{connectorEntity.status}, #{connectorEntity.podState}, #{connectorEntity.configIds})"
+ "</foreach>"
+ "</script>")
@Insert({
"<script>",
" INSERT INTO connector (cluster_id, name, class_name, type, status, pod_state, config_ids) VALUES ",
" <foreach collection='list' item='connectorEntity' index='index' separator=','>",
" (#{connectorEntity.clusterId}, #{connectorEntity.name}, #{connectorEntity.className},",
" #{connectorEntity.type}, #{connectorEntity.status}, #{connectorEntity.podState}, #{connectorEntity.configIds})",
" </foreach>",
"</script>"})
void batchInsert(List<ConnectorEntity> connectorEntityList);

@Update("UPDATE connector SET status = #{status} WHERE id = #{id}")
Expand All @@ -69,11 +69,11 @@ public interface ConnectorMapper {

@Update({
"<script>",
"update connector set status = 0 ",
"where id in ",
"<foreach collection='list' item='item' index='index' open='(' separator=',' close=')'>",
"#{item.id}",
"</foreach>",
" update connector set status = 0 ",
" where id in ",
" <foreach collection='list' item='item' index='index' open='(' separator=',' close=')'>",
" #{item.id}",
" </foreach>",
"</script>"
})
void batchDeActive(List<ConnectorEntity> connectorEntities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ public interface OprGroupMapper {
@Select("select * from `group` where id=#{id} and is_delete=0")
GroupEntity selectGroupById(GroupEntity groupEntity);

@Select("<script>"
+ "select * from `group`"
+ "<where>"
+ "<if test='clusterId != null'>"
+ "cluster_id=#{clusterId}"
+ "</if>"
+ "<if test='name != null'>"
+ "and name like concat('%',#{name},'%')"
+ "</if>"
+ "and is_delete=0"
+ "</where>"
+ "</script>")
@Select({
"<script>",
" select * from `group`",
" <where>",
" <if test='clusterId != null'>",
" cluster_id=#{clusterId}",
" </if>",
" <if test='name != null'>",
" and name like concat('%',#{name},'%')",
" </if>",
" and is_delete=0",
" </where>",
"</script>"})
List<GroupEntity> selectGroup(GroupEntity groupEntity);


}
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,22 @@ public interface OprGroupMemberMapper {
@Select("select * from group_member where id=#{id} and is_delete=0")
GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity);

@Select("<script>"
+ "select * from group_member"
+ "<where>"
+ "<if test='clusterId != null'>"
+ "cluster_id=#{clusterId}"
+ "</if>"
+ "<if test='groupName != null'>"
+ "and group_name=#{groupName}"
+ "</if>"
+ "<if test='topicName != null'>"
+ "and topic_name=#{topicName}"
+ "</if>"
+ "</where>"
+ "and is_delete=0"
+ "</script>")
@Select({
"<script>",
" select * from group_member",
" <where>",
" <if test='clusterId != null'>",
" cluster_id=#{clusterId}",
" </if>",
" <if test='groupName != null'>",
" and group_name=#{groupName}",
" </if>",
" <if test='topicName != null'>",
" and topic_name=#{topicName}",
" </if>",
" </where>",
" and is_delete=0",
"</script>"})
List<GroupMemberEntity> selectMember(GroupMemberEntity groupMemberEntity);

@Update("update group_member set state=#{state} where topic_name=#{topicName}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ List<HealthCheckResultEntity> selectByClusterIdAndCreateTimeRange(@Param("cluste

@Insert({
"<script>",
"INSERT INTO health_check_result(type, type_id, cluster_id, status, result_desc) VALUES ",
"<foreach collection='list' item='healthCheckResultEntity' index='index' separator=','>",
"(#{healthCheckResultEntity.type}, #{healthCheckResultEntity.typeId}, #{healthCheckResultEntity.clusterId},",
" #{healthCheckResultEntity.status}, #{healthCheckResultEntity.resultDesc})",
"</foreach>",
" INSERT INTO health_check_result(type, type_id, cluster_id, status, result_desc) VALUES ",
" <foreach collection='list' item='healthCheckResultEntity' index='index' separator=','>",
" (#{healthCheckResultEntity.type}, #{healthCheckResultEntity.typeId}, #{healthCheckResultEntity.clusterId},",
" #{healthCheckResultEntity.status}, #{healthCheckResultEntity.resultDesc})",
" </foreach>",
"</script>"
})
void batchInsert(List<HealthCheckResultEntity> healthCheckResultEntityList);
Expand All @@ -68,10 +68,12 @@ List<HealthCheckResultEntity> selectByClusterIdAndCreateTimeRange(@Param("cluste
void update(HealthCheckResultEntity healthCheckResultEntity);

@Update({
"<script><foreach collection='list' item='healthCheckResultEntity' index='index' separator=';'>",
"UPDATE health_check_result SET status = #{healthCheckResultEntity.status},",
"result_desc = #{healthCheckResultEntity.resultDesc} WHERE id = #{healthCheckResultEntity.id}",
"</foreach></script>"})
"<script>",
" <foreach collection='list' item='healthCheckResultEntity' index='index' separator=';'>",
" UPDATE health_check_result SET status = #{healthCheckResultEntity.status},",
" result_desc = #{healthCheckResultEntity.resultDesc} WHERE id = #{healthCheckResultEntity.id}",
" </foreach>",
"</script>"})
void batchUpdate(List<HealthCheckResultEntity> healthCheckResultEntityList);

@Select({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,22 @@
@Mapper
public interface OprLogMapper {

@Select("<script>"
+ "select * from operation_log"
+ "<where>"
+ "<if test='targetType!=null'>"
+ "target_type=#{targetType}"
+ "</if>"
+ "<if test='operationUser!=null'>"
+ "and operation_user=#{operationUser}"
+ "</if>"
+ "<if test='clusterId!=null'>"
+ "and cluster_id=#{clusterId} "
+ "</if>"
+ "and is_delete=0"
+ "</where>"
+ "</script>")
@Select({
"<script>",
" select * from operation_log",
" <where>",
" <if test='targetType!=null'>",
" target_type=#{targetType}",
" </if>",
" <if test='operationUser!=null'>",
" and operation_user=#{operationUser}",
" </if>",
" <if test='clusterId!=null'>",
" and cluster_id=#{clusterId} ",
" </if>",
" and is_delete=0",
" </where>",
"</script>"})
List<LogEntity> getLogList(LogEntity logEntity);

@Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@
@Mapper
public interface TopicMapper {

@Select("<script>"
+ "select * from topic"
+ "<where>"
+ "<if test='topicName!=null'>"
+ "and topic_name=#{topicName}"
+ "</if>"
+ "<if test='clusterId!=null'>"
+ "and cluster_id=#{clusterId} "
+ "</if>"
+ "and is_delete=0"
+ "</where>"
+ "</script>")
@Select({
"<script>",
" select * from topic",
" <where>",
" <if test='topicName!=null'>",
" and topic_name=#{topicName}",
" </if>",
" <if test='clusterId!=null'>",
" and cluster_id=#{clusterId} ",
" </if>",
" and is_delete=0",
" </where>",
"</script>"})
List<TopicEntity> getTopicList(TopicEntity topicEntity);

@Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) "
Expand Down
Loading
Loading