You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by xi...@apache.org on 2022/07/02 15:31:35 UTC

[incubator-shenyu] branch master updated: [ISSUE #3221]Feature/record log list/clean (#3635)

This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 489cfde32 [ISSUE #3221]Feature/record log list/clean (#3635)
489cfde32 is described below

commit 489cfde32192532b7f697b4c6c052dfad7c4e85c
Author: likeguo <33...@users.noreply.github.com>
AuthorDate: Sat Jul 2 23:31:30 2022 +0800

    [ISSUE #3221]Feature/record log list/clean (#3635)
    
    * fixbug/pg script error
    
    * feature/record-log-list-clean
    
    * feature/record-log-list-clean
    
    * feature/record-log-list-clean
    
    * feature/record-log-list-clean
    
    * feature/record-log-list-clean
    
    * feature/record-log-list-clean
---
 ...-debug-operation-record-log-controller-api.http |  23 ++++
 .../config/properties/DashboardProperties.java     |  26 +++++
 .../controller/OperationRecordLogController.java   |  27 ++++-
 .../admin/mapper/OperationRecordLogMapper.java     |  19 ++++
 .../admin/model/entity/OperationRecordLog.java     |   3 +
 .../admin/model/event/BatchChangedEvent.java       |   7 +-
 .../model/event/dict/BatchDictChangedEvent.java    |   7 +-
 .../admin/model/event/dict/DictChangedEvent.java   |   7 +-
 .../handle/BatchPluginHandleChangedEvent.java      |   7 +-
 .../event/handle/PluginHandleChangedEvent.java     |   7 +-
 .../event/metadata/BatchMetaDataChangedEvent.java  |   7 +-
 .../model/event/metadata/MetaDataChangedEvent.java |   7 +-
 .../event/plugin/BatchPluginChangedEvent.java      |   7 +-
 .../model/event/plugin/PluginChangedEvent.java     |   7 +-
 .../model/event/resource/ResourceChangedEvent.java |   7 +-
 .../admin/model/event/role/RoleChangedEvent.java   |   7 +-
 .../admin/model/event/role/RoleUpdatedEvent.java   |   7 +-
 .../admin/model/event/rule/RuleChangedEvent.java   |   7 +-
 .../model/event/selector/SelectorChangedEvent.java |   7 +-
 .../admin/model/event/user/UserChangedEvent.java   |   9 +-
 .../admin/model/query/RecordLogQueryCondition.java | 122 +++++++++++++++++++++
 .../admin/service/OperationRecordLogService.java   |  12 +-
 .../apache/shenyu/admin/service/PageService.java   |  10 ++
 .../impl/OperationRecordLogServiceImpl.java        |  21 ++++
 .../mappers/operation-record-log-sqlmap.xml        |  23 ++++
 .../org/apache/shenyu/common/utils/DateUtils.java  |  29 ++---
 26 files changed, 361 insertions(+), 61 deletions(-)

diff --git a/shenyu-admin/src/http/http-debug-operation-record-log-controller-api.http b/shenyu-admin/src/http/http-debug-operation-record-log-controller-api.http
index 9ea6e181f..906d3da4a 100644
--- a/shenyu-admin/src/http/http-debug-operation-record-log-controller-api.http
+++ b/shenyu-admin/src/http/http-debug-operation-record-log-controller-api.http
@@ -23,3 +23,26 @@ Accept: application/json
 Content-Type: application/json
 X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwNzg3NTY4fQ.YdxPSutcRClyuj76nYhwHJWkkkMzFVZeBfv5V04ybYA
 
+### list by page
+POST http://localhost:9095/operation-record/log/list/search/adaptor
+Accept: application/json
+Content-Type: application/json
+X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjU2NTk1Nzk1fQ.uBx8icElehCfjhXzOJYZUNLSI19RDS0ejrnKaoC510Y
+
+{
+  "pageSize": 10,
+  "pageNum": 1,
+  "condition": {
+    "startTime": "2022-04-19 17:07:21",
+    "endTime": "2022-06-19 17:07:21",
+    "type": "CREATE:DICT",
+    "keyword": "dict!name"
+  }
+}
+
+### clean
+DELETE http://localhost:9095/operation-record/log/clean/2022-04-25 23:31:31
+Accept: application/json
+Content-Type: application/json
+X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjU2NTk1Nzk1fQ.uBx8icElehCfjhXzOJYZUNLSI19RDS0ejrnKaoC510Y
+
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/DashboardProperties.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/DashboardProperties.java
index 13386868b..4c465970f 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/DashboardProperties.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/DashboardProperties.java
@@ -34,6 +34,14 @@ public class DashboardProperties {
     @Value("${shenyu.dashboard.core.record-log-limit:12}")
     private Integer recordLogLimit;
     
+    
+    /**
+     * Only supports deleting logs older than a certain day.
+     * default is 3.
+     */
+    @Value("${shenyu.dashboard.core.record-log-only-clean-days:3}")
+    private Integer onlyCleanDays;
+    
     /**
      * get recordLogLimit.
      *
@@ -51,4 +59,22 @@ public class DashboardProperties {
     public void setRecordLogLimit(final Integer recordLogLimit) {
         this.recordLogLimit = recordLogLimit;
     }
+    
+    /**
+     * get onlyCleanDays.
+     *
+     * @return days
+     */
+    public Integer getOnlyCleanDays() {
+        return onlyCleanDays;
+    }
+    
+    /**
+     * set onlyCleanDays.
+     *
+     * @param onlyCleanDays days
+     */
+    public void setOnlyCleanDays(final Integer onlyCleanDays) {
+        this.onlyCleanDays = onlyCleanDays;
+    }
 }
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java
index cfd411550..c4f1b038d 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/OperationRecordLogController.java
@@ -18,14 +18,22 @@
 package org.apache.shenyu.admin.controller;
 
 import org.apache.shenyu.admin.model.entity.OperationRecordLog;
+import org.apache.shenyu.admin.model.query.RecordLogQueryCondition;
 import org.apache.shenyu.admin.model.result.AdminResult;
 import org.apache.shenyu.admin.service.OperationRecordLogService;
+import org.apache.shenyu.admin.service.PageService;
 import org.apache.shenyu.admin.utils.ResultUtil;
+import org.apache.shenyu.common.utils.DateUtils;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -34,7 +42,7 @@ import java.util.List;
 @Validated
 @RestController
 @RequestMapping("/operation-record/log")
-public class OperationRecordLogController {
+public class OperationRecordLogController implements PagedController<RecordLogQueryCondition, OperationRecordLog> {
     
     private final OperationRecordLogService recordLogService;
     
@@ -51,4 +59,21 @@ public class OperationRecordLogController {
     public AdminResult<List<OperationRecordLog>> list() {
         return ResultUtil.ok(recordLogService.list());
     }
+    
+    /**
+     * clean.
+     *
+     * @param timePoint before time point
+     * @return list
+     */
+    @DeleteMapping("/clean/{timePoint}")
+    @RequiresPermissions("system:role:delete")
+    public AdminResult<Boolean> clean(@PathVariable @DateTimeFormat(pattern = DateUtils.DATE_FORMAT_DATETIME) final Date timePoint) {
+        return ResultUtil.ok(recordLogService.cleanHistory(timePoint));
+    }
+    
+    @Override
+    public PageService<RecordLogQueryCondition, OperationRecordLog> pageService() {
+        return recordLogService;
+    }
 }
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/OperationRecordLogMapper.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/OperationRecordLogMapper.java
index 26b30de38..dd449349f 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/OperationRecordLogMapper.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/OperationRecordLogMapper.java
@@ -20,7 +20,9 @@ package org.apache.shenyu.admin.mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.shenyu.admin.model.entity.OperationRecordLog;
+import org.apache.shenyu.admin.model.query.RecordLogQueryCondition;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -44,4 +46,21 @@ public interface OperationRecordLogMapper {
      * @return count change
      */
     int insert(OperationRecordLog recordLog);
+    
+    /**
+     * select by condition.
+     *
+     * @param condition condition
+     * @return list
+     */
+    List<OperationRecordLog> selectByCondition(@Param("condition") RecordLogQueryCondition condition);
+    
+    
+    /**
+     * delete data before time.
+     *
+     * @param time time
+     * @return time
+     */
+    int deleteByBefore(@Param("time") Date time);
 }
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/OperationRecordLog.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/OperationRecordLog.java
index c3955e97a..04b5e2918 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/OperationRecordLog.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/OperationRecordLog.java
@@ -18,6 +18,8 @@
 package org.apache.shenyu.admin.model.entity;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 
 import java.util.Date;
 
@@ -29,6 +31,7 @@ public class OperationRecordLog {
     /**
      * id.
      */
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long id;
     
     /**
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/BatchChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/BatchChangedEvent.java
index 27a811308..f3e76c357 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/BatchChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/BatchChangedEvent.java
@@ -31,9 +31,10 @@ public class BatchChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugin state
+     * @param type     event type
+     * @param operator operator
      */
     public BatchChangedEvent(final Collection<?> source, final Collection<?> before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/BatchDictChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/BatchDictChangedEvent.java
index 84f45de7b..dcd714372 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/BatchDictChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/BatchDictChangedEvent.java
@@ -34,9 +34,10 @@ public class BatchDictChangedEvent extends BatchChangedEvent {
     /**
      * Create a new {@code BatchDictChangedEvent}.operator is unknown.
      *
-     * @param source Current dict state
-     * @param before Before the change dict state
-     * @param type   event type
+     * @param source   Current dict state
+     * @param before   Before the change dict state
+     * @param type     event type
+     * @param operator operator
      */
     public BatchDictChangedEvent(final Collection<ShenyuDictDO> source, final Collection<ShenyuDictDO> before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/DictChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/DictChangedEvent.java
index 164d789d8..7003f40d0 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/DictChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/dict/DictChangedEvent.java
@@ -33,9 +33,10 @@ public class DictChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code DictChangedEvent}.operator is unknown.
      *
-     * @param source Current dict state
-     * @param before Before the change dict state
-     * @param type   event type
+     * @param source   Current dict state
+     * @param before   Before the change dict state
+     * @param type     event type
+     * @param operator operator
      */
     public DictChangedEvent(final ShenyuDictDO source, final ShenyuDictDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/BatchPluginHandleChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/BatchPluginHandleChangedEvent.java
index 898fbe878..52e477903 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/BatchPluginHandleChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/BatchPluginHandleChangedEvent.java
@@ -34,9 +34,10 @@ public class BatchPluginHandleChangedEvent extends BatchChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugin state
+     * @param type     event type
+     * @param operator operator
      */
     public BatchPluginHandleChangedEvent(final Collection<PluginHandleDO> source, final Collection<PluginHandleDO> before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/PluginHandleChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/PluginHandleChangedEvent.java
index 9ffbf7a77..d037e877c 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/PluginHandleChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/handle/PluginHandleChangedEvent.java
@@ -33,9 +33,10 @@ public class PluginHandleChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugiin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugiin state
+     * @param type     event type
+     * @param operator operator
      */
     public PluginHandleChangedEvent(final PluginHandleDO source, final PluginHandleDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/BatchMetaDataChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/BatchMetaDataChangedEvent.java
index 91f8b9b36..e6f52bc6a 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/BatchMetaDataChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/BatchMetaDataChangedEvent.java
@@ -34,9 +34,10 @@ public class BatchMetaDataChangedEvent extends BatchChangedEvent {
     /**
      * Create a new {@code BatchMetaDataChangedEvent}.operator is unknown.
      *
-     * @param source Current metadata state
-     * @param before Before the change metadata state
-     * @param type   event type
+     * @param source   Current metadata state
+     * @param before   Before the change metadata state
+     * @param type     event type
+     * @param operator operator
      */
     public BatchMetaDataChangedEvent(final Collection<MetaDataDO> source, final Collection<MetaDataDO> before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/MetaDataChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/MetaDataChangedEvent.java
index 11da20b0c..b8c471554 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/MetaDataChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/metadata/MetaDataChangedEvent.java
@@ -33,9 +33,10 @@ public class MetaDataChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugiin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugiin state
+     * @param type     event type
+     * @param operator operator
      */
     public MetaDataChangedEvent(final MetaDataDO source, final MetaDataDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/BatchPluginChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/BatchPluginChangedEvent.java
index 14947dbbd..c73ab6529 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/BatchPluginChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/BatchPluginChangedEvent.java
@@ -34,9 +34,10 @@ public class BatchPluginChangedEvent extends BatchChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugin state
+     * @param type     event type
+     * @param operator operator
      */
     public BatchPluginChangedEvent(final Collection<PluginDO> source, final Collection<PluginDO> before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/PluginChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/PluginChangedEvent.java
index 2d6816da7..d91366c0e 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/PluginChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/plugin/PluginChangedEvent.java
@@ -33,9 +33,10 @@ public class PluginChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugiin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugiin state
+     * @param type     event type
+     * @param operator operator
      */
     public PluginChangedEvent(final PluginDO source, final PluginDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/resource/ResourceChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/resource/ResourceChangedEvent.java
index 84fc19921..9e31ddcdd 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/resource/ResourceChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/resource/ResourceChangedEvent.java
@@ -33,9 +33,10 @@ public class ResourceChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code ResourceChangedEvent}.operator is unknown.
      *
-     * @param source Current rule state
-     * @param before Before the change rule state
-     * @param type   event type
+     * @param source   Current rule state
+     * @param before   Before the change rule state
+     * @param type     event type
+     * @param operator operator
      */
     public ResourceChangedEvent(final ResourceDO source, final ResourceDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleChangedEvent.java
index 965b1ad84..27fe68da8 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleChangedEvent.java
@@ -33,9 +33,10 @@ public class RoleChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code RoleChangedEvent}.operator is unknown.
      *
-     * @param source Current role state
-     * @param before Before the change role state
-     * @param type   event type
+     * @param source   Current role state
+     * @param before   Before the change role state
+     * @param type     event type
+     * @param operator operator
      */
     public RoleChangedEvent(final RoleDO source, final RoleDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleUpdatedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleUpdatedEvent.java
index 76ab10d05..c148c8264 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleUpdatedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/role/RoleUpdatedEvent.java
@@ -32,9 +32,10 @@ public class RoleUpdatedEvent extends RoleChangedEvent {
     /**
      * Create a new {@code RoleUpdatedEvent}.operator is unknown.
      *
-     * @param source   Current role state
-     * @param before   before role state
-     * @param operator operator
+     * @param source        Current role state
+     * @param before        before role state
+     * @param operator      operator
+     * @param newPermission newPermission
      */
     public RoleUpdatedEvent(final RoleDO source, final RoleDO before, final String operator, final List<String> newPermission) {
         super(source, before, EventTypeEnum.ROLE_UPDATE, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/rule/RuleChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/rule/RuleChangedEvent.java
index 0566698ea..39c49304b 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/rule/RuleChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/rule/RuleChangedEvent.java
@@ -33,9 +33,10 @@ public class RuleChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current rule state
-     * @param before Before the change rule state
-     * @param type   event type
+     * @param source   Current rule state
+     * @param before   Before the change rule state
+     * @param type     event type
+     * @param operator operator
      */
     public RuleChangedEvent(final RuleDO source, final RuleDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/selector/SelectorChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/selector/SelectorChangedEvent.java
index 0325653b6..479702a34 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/selector/SelectorChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/selector/SelectorChangedEvent.java
@@ -33,9 +33,10 @@ public class SelectorChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code PluginChangedEvent}.operator is unknown.
      *
-     * @param source Current plugin state
-     * @param before Before the change plugiin state
-     * @param type   event type
+     * @param source   Current plugin state
+     * @param before   Before the change plugiin state
+     * @param type     event type
+     * @param operator operator
      */
     public SelectorChangedEvent(final SelectorDO source, final SelectorDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/user/UserChangedEvent.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/user/UserChangedEvent.java
index ce39fd77e..b6c39fb27 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/user/UserChangedEvent.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/event/user/UserChangedEvent.java
@@ -33,9 +33,10 @@ public class UserChangedEvent extends AdminDataModelChangedEvent {
     /**
      * Create a new {@code UserChangedEvent}.operator is unknown.
      *
-     * @param source Current user state
-     * @param before Before the change user state
-     * @param type   event type
+     * @param source   Current user state
+     * @param before   Before the change user state
+     * @param type     event type
+     * @param operator operator
      */
     public UserChangedEvent(final DashboardUserDO source, final DashboardUserDO before, final EventTypeEnum type, final String operator) {
         super(source, before, type, operator);
@@ -81,7 +82,7 @@ public class UserChangedEvent extends AdminDataModelChangedEvent {
         if (!Objects.equals(before.getEnabled(), after.getEnabled())) {
             builder.append(String.format("enable[%s => %s] ", before.getEnabled(), after.getEnabled()));
         }
-
+        
         return builder.toString();
     }
     
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RecordLogQueryCondition.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RecordLogQueryCondition.java
new file mode 100644
index 000000000..1e1c64c75
--- /dev/null
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/query/RecordLogQueryCondition.java
@@ -0,0 +1,122 @@
+/*
+ * 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.shenyu.admin.model.query;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.shenyu.admin.model.page.condition.BaseExcludedSearchCondition;
+import org.apache.shenyu.admin.model.page.condition.SearchCondition;
+import org.apache.shenyu.common.utils.DateUtils;
+
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
+/**
+ * RecordLogQueryCondition.
+ */
+public class RecordLogQueryCondition extends BaseExcludedSearchCondition implements SearchCondition {
+    
+    /**
+     * search keyword: log context.
+     */
+    private String keyword;
+    
+    
+    /**
+     * log type.
+     */
+    private String type;
+    
+    /**
+     * start time.
+     */
+    @NotNull
+    @JsonFormat(pattern = DateUtils.DATE_FORMAT_DATETIME)
+    private Date startTime;
+    
+    /**
+     * end time.
+     */
+    @NotNull
+    @JsonFormat(pattern = DateUtils.DATE_FORMAT_DATETIME)
+    private Date endTime;
+    
+    @Override
+    public void setKeyword(final String keyword) {
+        this.keyword = keyword;
+    }
+    
+    @Override
+    public String getKeyword() {
+        return keyword;
+    }
+    
+    
+    /**
+     * get startTime.
+     *
+     * @return time
+     */
+    public Date getStartTime() {
+        return startTime;
+    }
+    
+    /**
+     * set startTime.
+     *
+     * @param startTime startTime
+     */
+    public void setStartTime(final Date startTime) {
+        this.startTime = startTime;
+    }
+    
+    /**
+     * get endTime.
+     *
+     * @return time
+     */
+    public Date getEndTime() {
+        return endTime;
+    }
+    
+    /**
+     * set endTime.
+     *
+     * @param endTime endTime
+     */
+    public void setEndTime(final Date endTime) {
+        this.endTime = endTime;
+    }
+    
+    /**
+     * get type.
+     *
+     * @return type
+     */
+    public String getType() {
+        return type;
+    }
+    
+    /**
+     * set type.
+     *
+     * @param type type
+     */
+    public void setType(final String type) {
+        this.type = type;
+    }
+}
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/OperationRecordLogService.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/OperationRecordLogService.java
index e4bb319a5..3c3153ae1 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/OperationRecordLogService.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/OperationRecordLogService.java
@@ -18,13 +18,15 @@
 package org.apache.shenyu.admin.service;
 
 import org.apache.shenyu.admin.model.entity.OperationRecordLog;
+import org.apache.shenyu.admin.model.query.RecordLogQueryCondition;
 
+import java.util.Date;
 import java.util.List;
 
 /**
  * OperationRecordLogService.
  */
-public interface OperationRecordLogService {
+public interface OperationRecordLogService extends PageService<RecordLogQueryCondition, OperationRecordLog> {
     
     /**
      * list.
@@ -32,4 +34,12 @@ public interface OperationRecordLogService {
      * @return list
      */
     List<OperationRecordLog> list();
+    
+    /**
+     * clean history.
+     *
+     * @param date before time point
+     * @return is success
+     */
+    boolean cleanHistory(Date date);
 }
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/PageService.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/PageService.java
index 286d71b54..33e046872 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/PageService.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/PageService.java
@@ -39,6 +39,7 @@ public interface PageService<Q, R> {
      * @return list
      */
     default PageInfo<R> searchByPage(final PageCondition<Q> pageCondition) {
+        doConditionPreProcessing(pageCondition.getCondition());
         PageHelper.startPage(pageCondition.getPageNum(), pageCondition.getPageSize());
         return new PageInfo<>(searchByCondition(pageCondition.getCondition()));
     }
@@ -66,4 +67,13 @@ public interface PageService<Q, R> {
         return new ArrayList<>();
     }
     
+    /**
+     * condition preprocessing.
+     *
+     * @param condition condition
+     */
+    default void doConditionPreProcessing(final Q condition) {
+        // default is nothing, override condition.
+    }
+    
 }
diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/OperationRecordLogServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/OperationRecordLogServiceImpl.java
index 854f32e79..376a5bff0 100644
--- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/OperationRecordLogServiceImpl.java
+++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/OperationRecordLogServiceImpl.java
@@ -20,9 +20,12 @@ package org.apache.shenyu.admin.service.impl;
 import org.apache.shenyu.admin.config.properties.DashboardProperties;
 import org.apache.shenyu.admin.mapper.OperationRecordLogMapper;
 import org.apache.shenyu.admin.model.entity.OperationRecordLog;
+import org.apache.shenyu.admin.model.query.RecordLogQueryCondition;
 import org.apache.shenyu.admin.service.OperationRecordLogService;
+import org.apache.shenyu.admin.utils.Assert;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -41,8 +44,26 @@ public class OperationRecordLogServiceImpl implements OperationRecordLogService
         this.dashboardProperties = dashboardProperties;
     }
     
+    @Override
+    public void doConditionPreProcessing(final RecordLogQueryCondition condition) {
+        condition.init();
+        Assert.isTrue(condition.getEndTime().getTime() > condition.getStartTime().getTime(), "end time must be greater than start time");
+    }
+    
+    @Override
+    public List<OperationRecordLog> searchByCondition(final RecordLogQueryCondition condition) {
+        return recordLogMapper.selectByCondition(condition);
+    }
+    
     @Override
     public List<OperationRecordLog> list() {
         return recordLogMapper.selectLimit(dashboardProperties.getRecordLogLimit());
     }
+    
+    @Override
+    public boolean cleanHistory(final Date date) {
+        final long supportMaxTime = System.currentTimeMillis() - (dashboardProperties.getOnlyCleanDays() * 1000 * 60 * 60 * 24);
+        Assert.isTrue(date.getTime() < supportMaxTime, String.format("Only supports cleaning data older than %d days", dashboardProperties.getOnlyCleanDays()));
+        return recordLogMapper.deleteByBefore(date) > 0;
+    }
 }
diff --git a/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml b/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
index 190ab6588..c93046a18 100644
--- a/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/operation-record-log-sqlmap.xml
@@ -37,6 +37,12 @@
         operation_type
     </sql>
 
+    <delete id="deleteByBefore">
+        delete
+        from operation_record_log
+        where operation_time <![CDATA[<]]> #{time}
+    </delete>
+
     <select id="selectLimit" parameterType="java.lang.Integer" resultMap="BaseResultMap">
         SELECT
                <include refid="Base_Column_List"/>
@@ -53,6 +59,23 @@
         order by operation_time desc
     </select>
 
+    <select id="selectByCondition" resultType="org.apache.shenyu.admin.model.entity.OperationRecordLog">
+        select
+        <include refid="Base_Column_List"/>
+        from operation_record_log
+        where operation_time between #{condition.startTime} and #{condition.endTime}
+        <if test="condition.keyword != null and condition.keyword != ''">
+            and context like concat('%',#{condition.keyword},'%')
+        </if>
+        <if test="condition.excluded != null and condition.excluded != ''">
+            and context not like concat('%',#{condition.excluded},'%')
+        </if>
+        <if test="condition.type != null">
+            and operation_type = #{condition.type}
+        </if>
+        order by operation_time desc
+    </select>
+
     <insert id="insert" parameterType="org.apache.shenyu.admin.model.entity.OperationRecordLog">
 
         <!-- Generate before inserting non auto increment PK -->
diff --git a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
index 1bff66e09..901fcc263 100644
--- a/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
+++ b/shenyu-common/src/main/java/org/apache/shenyu/common/utils/DateUtils.java
@@ -26,12 +26,15 @@ import java.time.temporal.ChronoUnit;
 /**
  * DateUtils.
  */
-public class DateUtils {
-
-    private static final String DATE_FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss";
-
+public final class DateUtils {
+    
+    public static final String DATE_FORMAT_DATETIME = "yyyy-MM-dd HH:mm:ss";
+    
     private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME);
-
+    
+    private DateUtils() {
+    }
+    
     /**
      * parse LocalDateTime.
      * out put format: yyyy-MM-dd HH:mm:ss
@@ -43,7 +46,7 @@ public class DateUtils {
     public static LocalDateTime parseLocalDateTime(final String dataTime) {
         return LocalDateTime.parse(dataTime, DateTimeFormatter.ofPattern(DATE_FORMAT_DATETIME));
     }
-
+    
     /**
      * Parse local date time local date time.
      *
@@ -54,19 +57,19 @@ public class DateUtils {
     public static LocalDateTime parseLocalDateTime(final String dataTime, final String dateTimeFormatter) {
         return LocalDateTime.parse(dataTime, DateTimeFormatter.ofPattern(dateTimeFormatter));
     }
-
+    
     /**
      * acquireMinutesBetween.
      *
      * @param start this is start date.
      * @param end   this is start date.
      * @return The number of days between start and end, if end is after start,
-     *         returns a positive number, otherwise returns a negative number.
+     *     returns a positive number, otherwise returns a negative number.
      */
     public static long acquireMinutesBetween(final LocalDateTime start, final LocalDateTime end) {
         return start.until(end, ChronoUnit.MINUTES);
     }
-
+    
     /**
      * Acquire millis between long.
      *
@@ -77,7 +80,7 @@ public class DateUtils {
     public static long acquireMillisBetween(final LocalDateTime start, final LocalDateTime end) {
         return start.until(end, ChronoUnit.MILLIS);
     }
-
+    
     /**
      * Format local date time from timestamp local date time.
      *
@@ -87,7 +90,7 @@ public class DateUtils {
     public static LocalDateTime formatLocalDateTimeFromTimestamp(final Long timestamp) {
         return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, ZoneOffset.ofHours(8));
     }
-
+    
     /**
      * Format local date time from timestamp by system time zone.
      *
@@ -97,7 +100,7 @@ public class DateUtils {
     public static LocalDateTime formatLocalDateTimeFromTimestampBySystemTimezone(final Long timestamp) {
         return LocalDateTime.ofEpochSecond(timestamp / 1000, 0, OffsetDateTime.now().getOffset());
     }
-
+    
     /**
      * Format local date time to string.
      * use default pattern yyyy-MM-dd HH:mm:ss
@@ -108,7 +111,7 @@ public class DateUtils {
     public static String localDateTimeToString(final LocalDateTime localDateTime) {
         return DATE_TIME_FORMATTER.format(localDateTime);
     }
-
+    
     /**
      * Format local date time to string.
      *