Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Config
    • Annotation
  • Core functions

    • Auto process index
    • CRUD
    • Condition constructor
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join Parent child
    • Get DSL
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match
    • Weight
    • Highlight
    • Geo
  • Plugin

    • Plugin
      • Interceptor plugin
        • Requirements Background
        • Usage example
        • Suggestions for Improvement
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v1.xDoc
  • Plugin
LaoHan
2023-03-18
目录

Plugin

The long-awaited plug-in module is here. In this module, you can use your imagination, open your mind, customize plug-ins, and develop some useful plug-ins according to your own project preferences. As long as there is value, you can submit PR, after the review, you can become an EE contributor, and the plugin can be used by developers around the world..

Notes

  • Plugin modules should be as independent of other modules as possible, especially the core module
  • Plug-in modules must not modify the code of other modules excessively. If there is any modification, the scope of influence needs to be evaluated
  • Plug-in modules should be configurable as much as possible. When not configured, the operation and performance safety of other modules cannot be affected.

image.png

# Interceptor plugin

This plugin is contributed by the open source team member: Mr. Lu

Applicable scenarios

Some methods require special preprocessing, such as:

  • Before performing the delete es data operation, you need to verify user permissions, or record operation records, etc.
  • You need to append some special parameters, such as logical deletion, before executing the query In short, it is the enhancement of AOP pre-interception for various APIs provided by EE.

# Requirements Background

It is necessary to intercept the selectList method provided by this framework, and then append the logical deletion to the undeleted state in the query parameters of this method as the query condition

# Usage example

Add an interceptor, specify the intercepted method list through the @Intercepts annotation, and specify the intercepted classes, methods, parameters and other information through the @Signature annotation.

@Intercepts(
        {
                @Signature(type = BaseEsMapper.class, method = "selectList", args = {LambdaEsQueryWrapper.class}),
        }
)
@Component
public class QueryInterceptor implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("Ah, ah, I intercepted the query and added query conditions uniformly");
        // The tombstone state is uniformly added to the query condition as undeleted
        Object[] args = invocation.getArgs();
        LambdaEsQueryWrapper<GeneralBean> arg = (LambdaEsQueryWrapper) args[0];
        arg.eq(GeneralBean::getExistStatus, true);
        return invocation.proceed();
    }

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

Tips

  1. This interceptor needs to be annotated with @Component and added to the Spring container, otherwise this interceptor will not take effect.
  2. The full path of the implemented Interceptor is: com.xpc.easyes.sample.interceptor, not other interceptors with the same name.

# Suggestions for Improvement

The granularity is too fine and does not support wildcards. For example, if I want to intercept 5 methods prefixed with selectXXX, I need to configure 5 times through annotations to achieve this. Subsequent suggestions can support wildcard interception, such as intercepting all methods starting with select in a specified class through select*. If I have time in subsequent iterations, I will optimize this place. If developers are interested, please submit improved code and contribute PR!

Help us improve this document (opens new window)
Last update: 2024/03/29
Geo
Faq

← Geo Faq→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式