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

edi.rule.frame.mybatis.dao.MapperForMysql Maven / Gradle / Ivy

package edi.rule.frame.mybatis.dao;

import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import edi.rule.config.JSRuleContext;
import edi.rule.config.JSRuleMessage;
import edi.rule.work.custom.JSRuleException;
import edi.rule.work.interfaces.IJSRuleMybatisMapper;

public interface MapperForMysql extends IJSRuleMybatisMapper{
	int addDataWithKey(String tableName,Map beanMap,Map fields);
	/*mysql特殊语法,要求所有数据集合中的所有数据的列数相同*/
	int addDataListForMysql(String tableName, Map firstData, List> dataList);
	default int addData(String tableName, List> dataList) {
		Map fields = dataList.get(0);
		int fieldsSize = fields.size();
		if (JSRuleContext.getProperties().open.replenishColumns) {
			int i=0;
			for (Map data:dataList) {
				if (fieldsSize==data.size()) {
					continue;
				}else {
					if (fieldsSize>data.size()) {
						for (Entry entry:fields.entrySet()) {
							data.putIfAbsent(entry.getKey(), null);
						}
					}else {
						throw new JSRuleException(JSRuleMessage.read("the.first.line.that.colum.quantity.can't.be.less.than.other.line"),String.valueOf(i));
					}
				}
				i++;
			}
		}
		return addDataListForMysql(tableName,fields,dataList);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy