From 311b6522d6472e882f9039e97a514a4bd7129be5 Mon Sep 17 00:00:00 2001 From: niudehua <657563945@qq.com> Date: Tue, 9 Mar 2021 00:57:44 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E5=B0=86=20DefaultParamHandler=20?= =?UTF-8?q?=E4=BB=8E=20config=20=E5=8C=85=E7=A7=BB=E5=8A=A8=E5=88=B0=20cor?= =?UTF-8?q?e/handle=20=E5=8C=85=E4=B8=8B=20=E5=B0=86=20DefaultParamHandler?= =?UTF-8?q?=20=E6=94=B9=E5=90=8D=E4=B8=BA=20DefaultDBFieldHandler"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ce7947b1 --- .../DefaultParamHandler.java} | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) rename src/main/java/cn/iocoder/dashboard/framework/mybatis/{core/handle/DefaultDBFieldHandler.java => config/DefaultParamHandler.java} (79%) diff --git a/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/handle/DefaultDBFieldHandler.java b/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/DefaultParamHandler.java similarity index 79% rename from src/main/java/cn/iocoder/dashboard/framework/mybatis/core/handle/DefaultDBFieldHandler.java rename to src/main/java/cn/iocoder/dashboard/framework/mybatis/config/DefaultParamHandler.java index fc3b3660e4..f94100fbce 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/mybatis/core/handle/DefaultDBFieldHandler.java +++ b/src/main/java/cn/iocoder/dashboard/framework/mybatis/config/DefaultParamHandler.java @@ -1,31 +1,24 @@ -package cn.iocoder.dashboard.framework.mybatis.core.handle; +package cn.iocoder.dashboard.framework.mybatis.config; import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.dashboard.framework.security.core.LoginUser; import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils; -import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; -import cn.iocoder.dashboard.modules.system.service.user.SysUserService; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; -import lombok.extern.slf4j.Slf4j; import org.apache.ibatis.reflection.MetaObject; import org.springframework.stereotype.Component; -import javax.annotation.Resource; import java.util.Date; import java.util.Objects; /** * 通用参数填充实现类 - *
+ * * 如果没有显式的对通用参数进行赋值,这里会对通用参数进行填充、赋值 * * @author hexiaowu */ @Component -@Slf4j -public class DefaultDBFieldHandler implements MetaObjectHandler { - @Resource - SysUserService userService; +public class DefaultParamHandler implements MetaObjectHandler { @Override public void insertFill(MetaObject metaObject) { @@ -55,11 +48,9 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { @Override public void updateFill(MetaObject metaObject) { - log.error("进来更新"); Object modifyTime = getFieldValByName("updateTime", metaObject); Object modifier = getFieldValByName("updater", metaObject); // 获取登录用户信息 - // TODO 获取不到 username LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); // 更新时间为空,则以当前时间为更新时间 @@ -68,9 +59,7 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { } // 当前登录用户不为空,更新人为空,则当前登录用户为更新人 if (Objects.nonNull(loginUser) && Objects.isNull(modifier)) { - Long id = loginUser.getId(); - SysUserDO user = userService.getUser(id); - setFieldValByName("updater", user.getUsername(), metaObject); + setFieldValByName("updater", loginUser.getId(), metaObject); } } }