package com.cpp.web.core.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.cpp.common.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 *  MyMetaObjectHandler
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {


    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("create_time", new Date(), metaObject);
//        setFieldValByName("create_by", SecurityUtils.getLoginUser().getUsername(), metaObject);
    }
    @Override
    public void updateFill(MetaObject metaObject) {
//        setFieldValByName("update_time", LocalDateTime.now(), metaObject);
//        setFieldValByName("update_by", SecurityUtils.getLoginUser().getUsername(), metaObject);
    }
}