master
parent
7864f3b4a6
commit
26bf367d53
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.common.datascope;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -14,18 +16,30 @@ import java.util.Date;
|
|||
* @name:MyMetaObjectHandler
|
||||
* @Date:2024/8/9 9:41
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler{
|
||||
|
||||
public MyMetaObjectHandler() {
|
||||
|
||||
log.info("元对象字段填充控制器 -------- 加载完成");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("createBy", SecurityUtils.getUserId(), metaObject);
|
||||
this.setFieldValByName("createBy", Convert.utf8Str(SecurityUtils.getUserId()), metaObject);
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
log.info("添加对象元数据字段填充-[createBy:{}],createTime:[{}]",
|
||||
SecurityUtils.getUserId(), new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
|
||||
this.setFieldValByName("updateBy", SecurityUtils.getUserId(), metaObject);
|
||||
this.setFieldValByName("updateBy", Convert.utf8Str(SecurityUtils.getUserId()), metaObject);
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
log.info("修改对象元数据字段填充-[updateBy:{}],updateTime:[{}]",
|
||||
SecurityUtils.getUserId(), new Date());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue