All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yu.base.pro.config.TimeHandler Maven / Gradle / Ivy

The newest version!
package com.github.yu.base.pro.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.github.yu.other.util.IdUtil;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;

/**
 * @author yu
 * 2022/5/25
 */
public class TimeHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", LocalDateTime::now, LocalDateTime.class);
        this.strictInsertFill(metaObject, "id", IdUtil::getSnowId, Long.class);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", LocalDateTime::now, LocalDateTime.class);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy