cn.meteor.common.database.handler.AbstractMetaObjectHandler Maven / Gradle / Ivy
package cn.meteor.common.database.handler;// Copyright (C), Created on 2021-04-03
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import java.util.Map;
/**
* 填充器
*
* @author ths
* @since 1.0.0
*/
@Slf4j
public abstract class AbstractMetaObjectHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
Map map = insertProperties();
map.forEach((key, value) -> this.setFieldValByName(key, value, metaObject));
}
@Override
public void updateFill(MetaObject metaObject) {
Map map = updateProperties();
map.forEach((key, value) -> this.setFieldValByName(key, value, metaObject));
}
/**
* 填充需要插入的字段
*
* @return 字段集合
*/
public abstract Map insertProperties();
/**
* 填充需要更新的字段
*
* @return 字段集合
*/
public abstract Map updateProperties();
}