我在 mybatis-config.xml 中定义了两个拦截器。
var mealDataDetail = ( _dbContext.Meal.Where(m => m.IsDeleted == 0 && m.UserId == userId).ToList()
.GroupJoin(_dbContext.MealImage.Where(i => i.IsDeleted == 0 && i.MealType == (int)mealType).ToList(), p => p.Id, r => r.MealId, (p, rs) => new { p, rs })
.GroupJoin(_dbContext.MealMenu.Where(i => i.IsDeleted == 0 && i.MealType == (int)mealType).ToList(), prs => prs.p.Id, c => c.MealId, (prs, cs) => new MealDataDetail
{
MealId = prs.p.Id,
MealData = new MealData
{
MealImages = prs.rs.Select(im => im.Image),
Description = prs.p.BreakfastDescription,
Time = prs.p.BreakfastTime,
TimeRequired = prs.p.BreakfastTimeRequired,
Appitite = prs.p.BreakfastAppetite,
Status = prs.p.BreakfastStatus == 1,
Calorie = prs.p.BreakfastCalorie,
},
}));
实施两个拦截器。
<plugins>
<plugin interceptor="cn.common.interceptor.DbInterceptor"/>
<plugin interceptor="cn.common.interceptor.MybatisInterceptor"/>
</plugins>
执行更新方法后, MybatisInterceptor 首次执行。
但我想首先执行 DbInterceptor 拦截器,我该怎么办?
答案 0 :(得分:0)
在MyBatis
中,后一个插件将首先被执行,所以我认为你只需要更改插件的配置顺序:
从
改变<plugins>
<plugin interceptor="cn.common.interceptor.DbInterceptor"/>
<plugin interceptor="cn.common.interceptor.MybatisInterceptor"/>
</plugins>
到
<plugins>
<plugin interceptor="cn.common.interceptor.MybatisInterceptor"/>
<plugin interceptor="cn.common.interceptor.DbInterceptor"/>
</plugins>
可以在 CSDN
找到更多详细信息