Skip to content

Commit

Permalink
fourth improve
Browse files Browse the repository at this point in the history
  • Loading branch information
zzxxiansheng committed Feb 1, 2024
1 parent c030859 commit a6b5caa
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

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

import java.sql.Timestamp;

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

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

import java.sql.Timestamp;

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

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

import java.sql.Timestamp;

Expand All @@ -34,7 +34,7 @@ public class LogEntity {

private String operationType;

private String operationTarget;
private String targetType;

private Integer status;

Expand All @@ -47,4 +47,5 @@ public class LogEntity {
private String operationUser;

private String resultContent;

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

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

import java.sql.Timestamp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.eventmesh.dashboard.console.log;

import org.apache.eventmesh.dashboard.console.annotation.EmLog;
import org.apache.eventmesh.dashboard.console.entity.LogEntity;
import org.apache.eventmesh.dashboard.console.entity.log.LogEntity;
import org.apache.eventmesh.dashboard.console.service.log.LogService;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -67,15 +67,17 @@ public Object logStart(ProceedingJoinPoint joinPoint) throws Throwable {
LogEntity logEntity = this.productLoEntity(declaredAnnotation, joinPoint);
logService.addLog(logEntity);
logEntity.setEndTime(new Timestamp(System.currentTimeMillis()));
Object proceed = null;
try {
Object proceed = joinPoint.proceed();
proceed = joinPoint.proceed();
logEntity.setStatus(2);
logEntity.setResultContent(Objects.isNull(proceed) ? "" : proceed.toString());
return proceed;
} catch (Throwable e) {
logEntity.setStatus(3);
throw new RuntimeException(e);
} finally {
logEntity.setResultContent(proceed.toString());
logService.updateLog(logEntity);
}

Expand All @@ -94,7 +96,7 @@ public LogEntity productLoEntity(EmLog declaredAnnotation, ProceedingJoinPoint j
logEntity.setClusterId(opClusterPhyId);
logEntity.setDescription(model.toString());
logEntity.setOperationType(declaredAnnotation.OprType());
logEntity.setOperationTarget(declaredAnnotation.OprTarget());
logEntity.setTargetType(declaredAnnotation.OprTarget());
logEntity.setStatus(1);
logEntity.setCreateTime(new Timestamp(System.currentTimeMillis()));
return logEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

import org.apache.eventmesh.dashboard.console.entity.GroupEntity;
import org.apache.eventmesh.dashboard.console.entity.group.GroupEntity;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
Expand All @@ -36,8 +36,7 @@ public interface OprGroupMapper {

@Insert("INSERT INTO `group` (cluster_id, name, member_count, members, type, state)"
+ "VALUE (#{clusterId},#{name},#{memberCount},#{members},#{type},#{state}) "
+ "on duplicate key update is_delete=0"
)
+ "on duplicate key update is_delete=0")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void addGroup(GroupEntity groupEntity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.eventmesh.dashboard.console.mapper.groupmember;


import org.apache.eventmesh.dashboard.console.entity.GroupMemberEntity;
import org.apache.eventmesh.dashboard.console.entity.groupmember.GroupMemberEntity;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
Expand All @@ -39,24 +39,24 @@ public interface OprGroupMemberMapper {
@Select("select * from group_member where cluster_id=#{clusterId} and is_delete=0")
List<GroupMemberEntity> getGroupByClusterId(GroupMemberEntity groupMemberEntity);

@Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user)"
+ " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser})"
@Insert("insert into group_member (cluster_id, topic_name, group_name, eventmesh_user,state)"
+ " VALUE (#{clusterId},#{topicName},#{groupName},#{eventMeshUser},#{state})"
+ "on duplicate key update is_delete=0")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
GroupMemberEntity addGroupMember(GroupMemberEntity groupMemberEntity);
void addGroupMember(GroupMemberEntity groupMemberEntity);

@Update("update group_member set state=#{state} where id=#{id}")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
GroupMemberEntity updateGroupMember(GroupMemberEntity groupMemberEntity);
void updateGroupMember(GroupMemberEntity groupMemberEntity);

@Delete("update group_member set is_delete=1 where id=#{id} ")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
GroupMemberEntity deleteGroupMember(GroupMemberEntity groupMemberEntity);

@Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName}")
@Select("select * from group_member where cluster_id=#{clusterId} and group_name=#{groupName} and topic_name=#{topicName} and is_delete=0")
GroupMemberEntity selectGroupMemberByUnique(GroupMemberEntity groupMemberEntity);

@Select("select * from group_member where id=#{id}")
@Select("select * from group_member where id=#{id} and is_delete=0")
GroupMemberEntity selectGroupMemberById(GroupMemberEntity groupMemberEntity);

@Select("<script>"
Expand All @@ -72,9 +72,10 @@ public interface OprGroupMemberMapper {
+ "and topic_name=#{topicName}"
+ "</if>"
+ "</where>"
+ "and is_delete=0"
+ "</script>")
List<GroupMemberEntity> selectAllMemberByDynamic(GroupMemberEntity groupMemberEntity);

@Update("update group_member set state=#{state} where topic_name=#{topicName}")
GroupMemberEntity updateMemberByTopic(GroupMemberEntity groupMemberEntity);
void updateMemberByTopic(GroupMemberEntity groupMemberEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

import org.apache.eventmesh.dashboard.console.entity.LogEntity;
import org.apache.eventmesh.dashboard.console.entity.log.LogEntity;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
Expand All @@ -36,22 +36,25 @@ public interface OprLogMapper {
@Select("<script>"
+ "select * from operation_log"
+ "<where>"
+ "<if test='targetType != null'>"
+ "<if test='targetType!=null'>"
+ "target_type=#{targetType}"
+ "</if>"
+ "<if test='clusterId != null'>"
+ "cluster_id=#{clusterId}"
+ "<if test='operationUser!=null'>"
+ "and operation_user=#{operationUser}"
+ "</if>"
+ "<if test='operationUser != null'>"
+ "operation_user=#{operationUser}"
+ "</if></where></script>")
+ "<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,operation_target, description,operation_user)"
+ "VALUE (#{clusterId},#{operationType},#{operationTarget},#{description},#{operationUser})")
@Insert("insert into operation_log ( cluster_id, operation_type,target_Type, description,operation_user,result_content)"
+ "VALUE (#{clusterId},#{operationType},#{targetType},#{description},#{operationUser},#{resultContent})")
@SelectKey(keyColumn = "id", statement = {" select last_insert_id()"}, keyProperty = "id", before = false, resultType = Long.class)
Long addLog(LogEntity logEntity);

@Update("update operation_log set status=#{status} where id=#{id}")
@Update("update operation_log set status=#{status} ,result_content=#{resultContent} where id=#{id}")
Integer updateLog(LogEntity logEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
package org.apache.eventmesh.dashboard.console.mapper.topic;


import org.apache.eventmesh.dashboard.console.entity.TopicEntity;
import org.apache.eventmesh.dashboard.console.entity.topic.TopicEntity;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

Expand All @@ -38,25 +39,28 @@ public interface TopicMapper {
@Select("<script>"
+ "select * from topic"
+ "<where>"
+ "<if test='clusterId != null'>"
+ "cluster_id=#{clusterId}"
+ "<if test='topicName!=null'>"
+ "and topic_name=#{topicName}"
+ "</if>"
+ "<if test='topicName != null'>"
+ "topic_name=#{topicName}"
+ "<if test='clusterId!=null'>"
+ "and cluster_id=#{clusterId} "
+ "</if>"
+ "and is_delete=0"
+ "</where>"
+ "</script>")
List<TopicEntity> getTopicListByClusterId(TopicEntity topicEntity);
List<TopicEntity> getTopicListByDynamic(TopicEntity topicEntity);

@Insert("INSERT INTO topic (cluster_id, topic_name, runtime_id, storage_id, retention_ms, type, description) "
+ "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})")
TopicEntity addTopic(TopicEntity topicEntity);
+ "VALUE (#{clusterId},#{topicName},#{runtimeId},#{storageId},#{retentionMs},#{type},#{description})"
+ "on duplicate key update is_delete = 0")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
void addTopic(TopicEntity topicEntity);

@Update("update topic set type=#{type},description=#{description} where id=#{id}")
TopicEntity updateTopic(TopicEntity topicEntity);
void updateTopic(TopicEntity topicEntity);

@Delete("update `topic` set is_delete=1 where id=#{id}")
TopicEntity deleteTopic(TopicEntity topicEntity);
void deleteTopic(TopicEntity topicEntity);

@Select("select * from topic where cluster_id=#{clusterId} and topic_name=#{topicName}")
TopicEntity selectTopicByUnique(TopicEntity topicEntity);
Expand Down

0 comments on commit a6b5caa

Please sign in to comment.