All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.meteor.common.database.handler.AbstractMetaObjectHandler Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
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();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy