public class LampMetaObjectHandler extends Object implements com.baomidou.mybatisplus.core.handlers.MetaObjectHandler
判断逻辑: 1. insert 方法,自动填充 id, createTime, updateTime, createdBy, updatedBy 字段,字段为空则自动生成,不为空则使用传递进来的 2. update 方法,自动填充 id, updateTime, updatedBy 字段,字段为空则自动生成,不为空则使用传递进来的
注入值: id: IdUtil.getSnowflake(workerId, dataCenterId); createTime:LocalDateTime.now() updateTime:LocalDateTime.now() createdBy:BaseContextHandler.getUserId() updatedBy:BaseContextHandler.getUserId()
| 构造器和说明 |
|---|
LampMetaObjectHandler() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
insertFill(org.apache.ibatis.reflection.MetaObject metaObject)
注意:不支持 复合主键 自动注入!!
|
void |
updateFill(org.apache.ibatis.reflection.MetaObject metaObject)
所有的继承了Entity、SuperEntity的实体,在update时,
updatedBy: 自动赋予 当前线程上的登录人id
updateTime: 自动赋予 服务器的当前时间
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfillStrategy, findTableInfo, getFieldValByName, openInsertFill, openUpdateFill, setFieldValByName, strictFill, strictFillStrategy, strictInsertFill, strictInsertFill, strictInsertFill, strictUpdateFill, strictUpdateFill, strictUpdateFillpublic void insertFill(org.apache.ibatis.reflection.MetaObject metaObject)
1、所有的继承了Entity、SuperEntity的实体,在insert时, id: id为空时, 通过IdGenerate生成唯一ID。 createdBy, updatedBy: 自动赋予 当前线程上的登录人id。 createTime, updateTime: 自动赋予 服务器的当前时间。
注意:实体中字段为空时才会赋值,若手动传值了,这里不会重新赋值
2、未继承任何父类的实体,且主键标注了 @TableId(value = "xxx", type = IdType.INPUT) 也能自动赋值,主键的字段名称任意
3、未继承任何父类的实体,但主键名为 id,也能自动赋值
insertFill 在接口中 com.baomidou.mybatisplus.core.handlers.MetaObjectHandlerpublic void updateFill(org.apache.ibatis.reflection.MetaObject metaObject)
updateFill 在接口中 com.baomidou.mybatisplus.core.handlers.MetaObjectHandlerCopyright © 2022. All rights reserved.