Commit 52ab4784 authored by yanzg's avatar yanzg

接口文档的支持

parent 8c810bf4
package com.yanzuoguang.dao.impl;
/**
* 累加接口
*
* @param <T>
*/
public interface GroupAdd<T extends GroupAdd> {
/***
* 自动累加接口
* @param from 累加接口
*/
void add(T from);
}
...@@ -683,4 +683,43 @@ public class TableStruct { ...@@ -683,4 +683,43 @@ public class TableStruct {
addWhereRemove(sql); addWhereRemove(sql);
sqlTableData.add(sql); sqlTableData.add(sql);
} }
/**
* 表结构累加
*
* @param froms 来源数据
* @param cls 类型
* @param <T>
* @return
*/
public static <T extends GroupAdd> List<T> megerGroupAdd(List<T> froms, Class<T> cls) {
List<T> tos = new ArrayList<>();
Map<String, T> mapFrom = new HashMap<>();
TableStruct tableStruct = new TableStruct(StringHelper.EMPTY, cls);
List<TableFieldVo> fields = tableStruct.getGroupLatitudeFields();
for (T from : froms) {
StringBuilder sb = new StringBuilder();
for (TableFieldVo field : fields) {
String value = StringHelper.getFirst(ObjectHelper.getString(from, field.inputName));
sb.append(value);
sb.append(":");
}
String key = StringHelper.getIdMD5(sb.toString());
if (!mapFrom.containsKey(key)) {
tos.add(from);
mapFrom.put(key, from);
} else {
T histor = mapFrom.get(key);
histor.add(from);
}
}
return tos;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment