package com.ruoyi.zzb.common.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * mybatisplus 属性默认值自动填充配置
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "approveTime", Date.class, new Date());
        this.strictInsertFill(metaObject, "isDelete", Integer.class, 0);
//        this.strictInsertFill(metaObject, "flag", Integer.class, 1);
        this.strictInsertFill(metaObject, "approveStatusCode", String.class, "0");
        this.strictInsertFill(metaObject, "approveStatusName", String.class, "待审核");
    }


    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
    }

}
