mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	update 优化 去除自动注入日志警告改为默认值 避免一大堆人去定时任务搞什么登录
This commit is contained in:
		@@ -22,6 +22,11 @@ import java.util.Date;
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class InjectionMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 如果用户不存在默认注入-1代表无用户
 | 
			
		||||
     */
 | 
			
		||||
    private static final Long DEFAULT_USER_ID = -1L;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 插入填充方法,用于在插入数据时自动填充实体对象中的创建时间、更新时间、创建人、更新人等信息
 | 
			
		||||
     *
 | 
			
		||||
@@ -45,6 +50,11 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
                        baseEntity.setCreateBy(userId);
 | 
			
		||||
                        baseEntity.setUpdateBy(userId);
 | 
			
		||||
                        baseEntity.setCreateDept(ObjectUtils.notNull(baseEntity.getCreateDept(), loginUser.getDeptId()));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        // 填充创建人、更新人和创建部门信息
 | 
			
		||||
                        baseEntity.setCreateBy(DEFAULT_USER_ID);
 | 
			
		||||
                        baseEntity.setUpdateBy(DEFAULT_USER_ID);
 | 
			
		||||
                        baseEntity.setCreateDept(ObjectUtils.notNull(baseEntity.getCreateDept(), DEFAULT_USER_ID));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
@@ -74,6 +84,8 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
                Long userId = LoginHelper.getUserId();
 | 
			
		||||
                if (ObjectUtil.isNotNull(userId)) {
 | 
			
		||||
                    baseEntity.setUpdateBy(userId);
 | 
			
		||||
                } else {
 | 
			
		||||
                    baseEntity.setUpdateBy(DEFAULT_USER_ID);
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
 | 
			
		||||
@@ -93,7 +105,6 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
 | 
			
		||||
        try {
 | 
			
		||||
            loginUser = LoginHelper.getLoginUser();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            log.warn("自动注入警告 => 用户未登录");
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return loginUser;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user