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

ys.artifact-orm.1.0.1.source-code.dao-common.btl Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
	@Override
	protected String getDBName() {
		return "${database.designConfig.databaseName}";
	}
	
	@Override
	protected String getTableName() {
		return "${table.tableName}";
	}
	
	@Override
	protected Class<${table.className}> getEntityClass(){
		return ${table.className}.class;
	}
	
	@Override
	protected ${table.className} createEntity() {
		return new ${table.className}() {};
	}

	@Override
	protected String getPKFieldName() {
		return "${table.pk.fieldName}";
	}
	
	// 根据主键导出
	public java.util.Map exportByPrimaryKey(${table.pk.type} ${table.pk.fieldName}){
		return export(findByPrimaryKey(${table.pk.fieldName}));
	}
	
	<%
	for(index in table.indexs){
	var methodSuffix = "";
	var parameter = "";
	var values = "";
	for(column in index.columns){
		var ColumnName = uf(column.fieldName);
		var columnName = lf(column.fieldName);
		methodSuffix = methodSuffix + ColumnName;
		parameter = parameter + column.type + " " + columnName;
		values = values + columnName;
		if(!columnLP.last){
			parameter = parameter + " ,";
			values = values + " ,";
		}
	}
	%>
	<%if(index.unique){%>
	public java.util.Map exportBy${methodSuffix}(${parameter}){
		return export(findBy${methodSuffix}(${values}));
	}
	<%}else{%>
	public java.util.List> exportBy${methodSuffix}(${parameter}){
		return export(findBy${methodSuffix}(${values}));
	}
	<%}%>
	<%}%>
	
	private java.util.Map export(${table.className} ${lf(table.className)}){
		java.util.Map data = new java.util.HashMap<>();
		data.put("self", ${lf(table.className)});
		<%if(table.relations.~size > 0){%>
		java.util.Map nodes = new java.util.HashMap<>();
		data.put("nodes", nodes);
		/**
		 * 此处可优化为并发加载,可选方式有executor.invokeAll、forkjoin都可以。暂时不做优化处理
		 */
		<%for(relation in table.relations){%>
		nodes.put("${lf(relation.table.ClassName)+"."+ lf(relation.column.fieldName)}",get${relation.table.ClassName + templates['DaoTemplate'].classSuffix}().exportBy${uf(relation.column.fieldName)}((${table.pk.type}) ${lf(table.className)}.pk()));
		<%}%>
		<%}%>
		return data;
	}
	
	private java.util.List> export(List<${table.className}> ${lf(table.className)}s){
		java.util.List> data = new java.util.ArrayList<>();
		for(${table.className} ${lf(table.className)} : ${lf(table.className)}s){
			data.add(export(${lf(table.className)}));
		}
		return data;
	}
	
	<%for(relation in table.relations){%>
	protected abstract ${relation.table.ClassName + templates['DaoTemplate'].classSuffix} get${relation.table.ClassName + templates['DaoTemplate'].classSuffix}();
	<%}%>
	




© 2015 - 2024 Weber Informatics LLC | Privacy Policy