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.md
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Spring Integration Guide
    • Solon Integration Guide
    • Config
    • Annotation
  • Core function

    • Condition constructor

      • Introduction of Wrapper
      • Index wrapper
      • Select wrapper
      • Update wrapper
    • Index CRUD

      • Index hosting model
      • Index CRUD
    • Data CRUD

      • Data synchronization solutions
      • Data CRUD
    • Multiple data sources support
    • Dynamic indexing support
    • Four nested query
    • Chain call
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join parent child
    • Get DSL
    • ExecuteDSL
    • Execute SQL
    • Custom RequestOptions
    • Custom default method
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match&fuzzy match
    • Weight
    • Highlight
    • Geo
    • IP
  • Plugin

    • Plugin
      • Interceptor plug-in
        • requirements background
        • Example of use
        • Suggestions for improvement
  • Other

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

Plugin

The long-awaited plug-in module is here, in this module you can use their imagination, brainstorming, custom plug-ins, according to their own project preferences to develop some good plug-ins, as long as there is value, can be submitted to the PR, the review can become EE contributors, the plug-in can be used by developers worldwide.

Caution

  • Plugin modules should be independent of other modules, especially the core module
  • Plugin modules should not overly modify other modules code, if there are changes, need to assess the impact of the scope
  • Plug-in module as far as possible to do configurable, not configured to open, not to affect the operation of other modules and performance security, etc.

image.png

# Interceptor plug-in

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

Applicable scenarios

Need to do special preprocessing for some methods, for example:

  • Need to delete data in the implementation of the operation before the need to verify user permissions, or record the operation records, etc.
  • Need to execute the query before the append some special parameters, such as logical deletion In short, it is a variety of APIs provided by EE to enhance the AOP pre-interception.

# requirements background

need to intercept the framework provides the selectList method , and then the query parameters in this method to append the logical deletion of the undeleted state as a query condition

# Example of use

Add a new interceptor , the @Intercepts annotation specifies the intercepted method list , the @Signature annotation specifies the intercepted class , method , parameters and other information .

@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("Ahhhhhh, I intercepted the query, add the query condition uniformly");
        // query conditions uniformly add logic to delete the state as not deleted
        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

提示

  1. you need to add @Component annotation to this interceptor and add it to Spring container, otherwise this interceptor will not work.
  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, does not support wildcards, for example, I want to intercept 5 methods prefixed with selectXXX, I need to configure 5 times by annotation to achieve, Subsequent suggestions can support wildcard interception, such as through select * intercept all methods in the specified class to select first. Subsequent iterations if I have time to optimize here, if there are developers interested in submitting improved code, contribute PR!

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

← IP Faq→

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