mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	项目结构调整 x 15 : 将 web、security、operatelog 等组件拆分出去
This commit is contained in:
		| @@ -1,8 +1,7 @@ | ||||
| package cn.iocoder.yudao.framework.mybatis.core.handler; | ||||
|  | ||||
| import cn.iocoder.yudao.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.yudao.framework.web.core.util.WebFrameworkUtils; | ||||
| import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; | ||||
| import org.apache.ibatis.reflection.MetaObject; | ||||
|  | ||||
| @@ -21,10 +20,9 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { | ||||
|     @Override | ||||
|     public void insertFill(MetaObject metaObject) { | ||||
|         if (Objects.nonNull(metaObject) && metaObject.getOriginalObject() instanceof BaseDO) { | ||||
|             LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); | ||||
|             BaseDO baseDO = (BaseDO) metaObject.getOriginalObject(); | ||||
|             Date current = new Date(); | ||||
|  | ||||
|             Date current = new Date(); | ||||
|             // 创建时间为空,则以当前时间为插入时间 | ||||
|             if (Objects.isNull(baseDO.getCreateTime())) { | ||||
|                 baseDO.setCreateTime(current); | ||||
| @@ -33,31 +31,32 @@ public class DefaultDBFieldHandler implements MetaObjectHandler { | ||||
|             if (Objects.isNull(baseDO.getUpdateTime())) { | ||||
|                 baseDO.setUpdateTime(current); | ||||
|             } | ||||
|  | ||||
|             Long userId = WebFrameworkUtils.getLoginUserId(); | ||||
|             // 当前登录用户不为空,创建人为空,则当前登录用户为创建人 | ||||
|             if (Objects.nonNull(loginUser) && Objects.isNull(baseDO.getCreator())) { | ||||
|                 baseDO.setCreator(loginUser.getId().toString()); | ||||
|             if (Objects.nonNull(userId) && Objects.isNull(baseDO.getCreator())) { | ||||
|                 baseDO.setCreator(userId.toString()); | ||||
|             } | ||||
|             // 当前登录用户不为空,更新人为空,则当前登录用户为更新人 | ||||
|             if (Objects.nonNull(loginUser) && Objects.isNull(baseDO.getUpdater())) { | ||||
|                 baseDO.setUpdater(loginUser.getId().toString()); | ||||
|             if (Objects.nonNull(userId) && Objects.isNull(baseDO.getUpdater())) { | ||||
|                 baseDO.setUpdater(userId.toString()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateFill(MetaObject metaObject) { | ||||
|         Object modifyTime = getFieldValByName("updateTime", metaObject); | ||||
|         Object modifier = getFieldValByName("updater", metaObject); | ||||
|         // 获取登录用户信息 | ||||
|         LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); | ||||
|  | ||||
|         // 更新时间为空,则以当前时间为更新时间 | ||||
|         Object modifyTime = getFieldValByName("updateTime", metaObject); | ||||
|         if (Objects.isNull(modifyTime)) { | ||||
|             setFieldValByName("updateTime", new Date(), metaObject); | ||||
|         } | ||||
|  | ||||
|         // 当前登录用户不为空,更新人为空,则当前登录用户为更新人 | ||||
|         if (Objects.nonNull(loginUser) && Objects.isNull(modifier)) { | ||||
|             setFieldValByName("updater", loginUser.getId().toString(), metaObject); | ||||
|         Object modifier = getFieldValByName("updater", metaObject); | ||||
|         Long userId = WebFrameworkUtils.getLoginUserId(); | ||||
|         if (Objects.nonNull(userId) && Objects.isNull(modifier)) { | ||||
|             setFieldValByName("updater", userId.toString(), metaObject); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV