You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.supervision.config ;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler ;
import org.apache.ibatis.reflection.MetaObject ;
import org.springframework.stereotype.Component ;
import java.util.Date ;
/**
* @author ljt on 2022/08/13.
* 创建时间和更新时间自动填充
*/
@Component
public class MyBatisMetaObjectHandler implements MetaObjectHandler {
// 使用MP进行添加操作, 该方法执行
@Override
public void insertFill ( MetaObject metaObject ) {
//属性名称,不是字段名称
this . setFieldValByName ( "createTime" , new Date ( ) , metaObject ) ;
this . setFieldValByName ( "updateTime" , new Date ( ) , metaObject ) ;
}
@Override
public void updateFill ( MetaObject metaObject ) {
// 使用MP进行修改操作, 该方法执行
this . setFieldValByName ( "updateTime" , new Date ( ) , metaObject ) ;
}
}