feat():增加输入插件的元数据的声明

master
Yueng 2024-08-11 09:30:59 +08:00
parent 0bfde66b29
commit 29d7b8da5a
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,36 @@
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 java.util.Date;
/**
*/
@Log4j2
public class MyMetaObjectHandler implements MetaObjectHandler {
public MyMetaObjectHandler() {
log.info("元对象字段填充控制器 -------- 加载完成");
}
@Override
public void insertFill(MetaObject 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", Convert.utf8Str(SecurityUtils.getUserId()), metaObject);
this.setFieldValByName("updateTime", new Date(), metaObject);
log.info("修改对象元数据字段填充-[updateBy:[{}],updateTime:[{}]",
SecurityUtils.getUserId(), new Date());
}
}

View File

@ -1 +1,2 @@
com.muyu.common.datascope.aspect.DataScopeAspect
com.muyu.common.datascope.MyMetaObjectHandler