package com.qmth.themis.business.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.qmth.themis.business.constant.SystemConstant;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @Description: mybatis 自动插入时间和id
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/4/20
 */
@Component
public class MetaHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName(SystemConstant.CREATE_TIME, System.currentTimeMillis(), metaObject);
        this.setFieldValByName(SystemConstant.UPDATE_TIME, System.currentTimeMillis(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName(SystemConstant.UPDATE_TIME, System.currentTimeMillis(), metaObject);
    }
}
