package com.ktg.framework.config;

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

/**
 * mybatis-plus自动填充
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createBy",String.class, SecurityUtils.getLoginUser().getUsername());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject,"updateBy",String.class,SecurityUtils.getLoginUser().getUsername());
    }
}
