mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-11-30 11:07:41 +08:00
plugin: Add history elapsed
This commit is contained in:
parent
710c82d36e
commit
0e2da300f4
@ -11,6 +11,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
@ -23,6 +25,7 @@ public class AuditPluginHandler
|
||||
{
|
||||
private final PluginAuditRepository pluginAuditRepository;
|
||||
private final SourceRepository sourceRepository;
|
||||
private PluginAuditEntity pluginAudit;
|
||||
|
||||
public AuditPluginHandler(PluginAuditRepository pluginAuditRepository, SourceRepository sourceRepository)
|
||||
{
|
||||
@ -30,11 +33,21 @@ public class AuditPluginHandler
|
||||
this.sourceRepository = sourceRepository;
|
||||
}
|
||||
|
||||
@Pointcut("@annotation(auditPlugin)")
|
||||
public void cut(AuditPlugin auditPlugin)
|
||||
{
|
||||
}
|
||||
|
||||
@Before("cut(auditPlugin)")
|
||||
public void doBefore(AuditPlugin auditPlugin)
|
||||
{
|
||||
this.pluginAudit = new PluginAuditEntity();
|
||||
pluginAudit.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
}
|
||||
|
||||
@AfterReturning(pointcut = "@annotation(auditPlugin)", returning = "jsonResult")
|
||||
public void doAfterReturning(JoinPoint joinPoint, AuditPlugin auditPlugin, Response jsonResult)
|
||||
{
|
||||
PluginAuditEntity pluginAudit = new PluginAuditEntity();
|
||||
pluginAudit.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
|
||||
handlerPlugin(joinPoint, pluginAudit, jsonResult);
|
||||
}
|
||||
|
||||
|
@ -50,8 +50,17 @@ public class PluginAuditEntity
|
||||
@Column(name = "end_time", columnDefinition = "datetime(5) default CURRENT_TIMESTAMP()")
|
||||
private Timestamp endTime;
|
||||
|
||||
@Column(name = "elapsed")
|
||||
private Long elapsed;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "plugin_id")
|
||||
@JsonIncludeProperties(value = {"name", "type"})
|
||||
private SourceEntity plugin;
|
||||
|
||||
public void setEndTime(Timestamp endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
this.elapsed = this.endTime.getTime() - this.createTime.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,3 @@ CREATE TABLE IF NOT EXISTS `source`
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARSET = utf8
|
||||
COLLATE = utf8_bin COMMENT ='The storage is used to query the data connection source';
|
||||
|
||||
-- If it already contains historical data, please use the following script to fix it
|
||||
ALTER TABLE `datacap`.`audit_plugin`
|
||||
MODIFY COLUMN `create_time` timestamp(5) NULL DEFAULT CURRENT_TIMESTAMP(5),
|
||||
MODIFY COLUMN `end_time` timestamp(5) NULL DEFAULT CURRENT_TIMESTAMP(5);
|
||||
|
6
server/src/main/schema/merge_1.0.0.20221015.sql
Normal file
6
server/src/main/schema/merge_1.0.0.20221015.sql
Normal file
@ -0,0 +1,6 @@
|
||||
-- If it already contains historical data, please use the following script to fix it
|
||||
ALTER TABLE `datacap`.`audit_plugin`
|
||||
MODIFY COLUMN `create_time` timestamp(5) NULL DEFAULT CURRENT_TIMESTAMP(5),
|
||||
MODIFY COLUMN `end_time` timestamp(5) NULL DEFAULT CURRENT_TIMESTAMP(5);
|
||||
ALTER TABLE `datacap`.`audit_plugin`
|
||||
ADD COLUMN `elapsed` bigint NULL DEFAULT 0;
|
@ -26,6 +26,12 @@ const headers = [
|
||||
key: 'endTime',
|
||||
ellipsis: true
|
||||
},
|
||||
{
|
||||
title: 'Elapsed',
|
||||
name: 'elapsed',
|
||||
dataIndex: 'elapsed',
|
||||
key: 'elapsed'
|
||||
},
|
||||
{
|
||||
title: 'State',
|
||||
name: 'state',
|
||||
|
@ -3,6 +3,18 @@
|
||||
<a-card title="Plugin Audit" size="small">
|
||||
<a-table size="middle" :loading="loading" :columns="headers" :data-source="columns" :pagination="pagination"
|
||||
@change="handlerTableChange($event)">
|
||||
<template #headerCell="{ column }">
|
||||
<template v-if="column.key === 'elapsed'">
|
||||
<span>
|
||||
{{column.title}}
|
||||
<a-tooltip>
|
||||
<template #title>The value is expressed in milliseconds</template>
|
||||
<question-circle-outlined />
|
||||
</a-tooltip>
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'plugin'">
|
||||
{{record.plugin.name}}
|
||||
|
Loading…
Reference in New Issue
Block a user