-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 支持@InterceptorIgnore作用在default方法上. #6613 * 新增插件跳过执行方法.
- Loading branch information
1 parent
feb80ff
commit 5d280b4
Showing
5 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
mybatis-plus/src/test/java/com/baomidou/mybatisplus/test/tenant/EntityMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,43 @@ | ||
package com.baomidou.mybatisplus.test.tenant; | ||
|
||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; | ||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
import org.apache.ibatis.annotations.CacheNamespace; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* @author miemie | ||
* @since 2020-06-24 | ||
*/ | ||
@CacheNamespace | ||
public interface EntityMapper extends BaseMapper<Entity> { | ||
|
||
/* | ||
* 请注意: Mybatis的接口方法虽然支持重载,但是底层MappedStatement是只能有一份的,也就是MappedStatement(类名+方法名)组成唯一性. | ||
* | ||
* 低版本(<3.5.10)下,忽略BaseMapper上的方法,可通过重写其中方法来标记 | ||
* 例如忽略deleteById方法,直接覆写 int deleteById(Entity entity); 这样就会把deleteById相关的重载方法都会重写掉,因为忽略方式是对MappedStatement级别生效的 | ||
* | ||
* (高版本才支持) | ||
* 但是建议按照如果有需要跳过一些插件的方法,通过自定义方法标记作用跳过会好点. | ||
* 例如我调用deleteById,默认情况下是需要拼接租户条件的,但如果有些特殊需求,想忽略跳过租户的时候,可以直接自定义个默认方法(例如deleteByIdWithIgnore)来调用baseMapper方法得deleteById | ||
*/ | ||
|
||
@InterceptorIgnore(tenantLine = "true") | ||
default int deleteByIdWithIgnore(Serializable id) { | ||
return deleteById(id); | ||
} | ||
|
||
@InterceptorIgnore(tenantLine = "true") | ||
default Entity selectByIdWithIgnore(Serializable id) { | ||
return selectById(id); | ||
} | ||
|
||
// /** | ||
// * //TODO 由于是对ms级别的忽略,所以不考虑重载方法, 忽略deleteById方法 | ||
// */ | ||
// @InterceptorIgnore(tenantLine = "true") | ||
// int deleteById(Entity entity); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters