From 9209e8da1c54ca0b09645a47086ee15479c83113 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 19 Mar 2022 18:13:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8F=9C=E5=8D=95=E3=80=81?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=88=A0=E9=99=A4=E6=97=B6=EF=BC=8C=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=9C=AA=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/system/dal/mysql/permission/MenuMapper.java | 8 +++----- .../module/system/dal/mysql/permission/RoleMapper.java | 10 +++------- .../system/service/permission/MenuServiceImpl.java | 2 +- .../system/service/permission/RoleServiceImpl.java | 2 +- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java index fc2718122..7a9fbfc1e 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java @@ -1,12 +1,12 @@ package cn.iocoder.yudao.module.system.dal.mysql.permission; -import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import java.util.Date; import java.util.List; @@ -28,9 +28,7 @@ public interface MenuMapper extends BaseMapperX { .eqIfPresent(MenuDO::getStatus, reqVO.getStatus())); } - default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) { - return selectOne(new LambdaQueryWrapper().select(MenuDO::getId) - .gt(MenuDO::getUpdateTime, maxUpdateTime).last(SqlConstants.LIMIT1)) != null; - } + @Select("SELECT id FROM system_menu WHERE update_time > #{maxUpdateTime} LIMIT 1") + MenuDO selectExistsByUpdateTimeAfter(Date maxUpdateTime); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/RoleMapper.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/RoleMapper.java index 1de536caf..c10cfa09b 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/RoleMapper.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/RoleMapper.java @@ -7,9 +7,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; -import com.baomidou.mybatisplus.annotation.InterceptorIgnore; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import org.springframework.lang.Nullable; import java.util.Collection; @@ -45,10 +44,7 @@ public interface RoleMapper extends BaseMapperX { return selectList(new LambdaQueryWrapperX().inIfPresent(RoleDO::getStatus, statuses)); } - @InterceptorIgnore(tenantLine = "true") // 该方法忽略多租户。原因:该方法被异步 task 调用,此时获取不到租户编号 - default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) { - return selectOne(new QueryWrapper().select("id") - .gt("update_time", maxUpdateTime).last("LIMIT 1")) != null; - } + @Select("SELECT id FROM system_role WHERE update_time > #{maxUpdateTime} LIMIT 1") + RoleDO selectExistsByUpdateTimeAfter(Date maxUpdateTime); } diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java index c54a490a6..149f6c7b4 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java @@ -120,7 +120,7 @@ public class MenuServiceImpl implements MenuService { if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 log.info("[loadMenuIfUpdate][首次加载全量菜单]"); } else { // 判断数据库中是否有更新的菜单 - if (!menuMapper.selectExistsByUpdateTimeAfter(maxUpdateTime)) { + if (menuMapper.selectExistsByUpdateTimeAfter(maxUpdateTime) == null) { return null; } log.info("[loadMenuIfUpdate][增量加载全量菜单]"); diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java index 16e584964..713b7e4db 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java @@ -116,7 +116,7 @@ public class RoleServiceImpl implements RoleService { if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 log.info("[loadRoleIfUpdate][首次加载全量角色]"); } else { // 判断数据库中是否有更新的角色 - if (!roleMapper.selectExistsByUpdateTimeAfter(maxUpdateTime)) { + if (roleMapper.selectExistsByUpdateTimeAfter(maxUpdateTime) == null) { return null; } log.info("[loadRoleIfUpdate][增量加载全量角色]");