Commit fa6f1bc6 authored by yanzg's avatar yanzg

接口文档的支持

parent dacd0830
package com.yanzuoguang.util.vo;
/**
* 获取关键字
*
* @param <T>
* @author 颜佐光
*/
public interface DataDaoKey<T extends Object> {
/**
* 获取关键字
*
* @param from 来源对象
* @return
*/
String getKey(T from);
/**
* 将当前对象的属性,写入到历史对象中,用于更新函数
*
* @param history
* @param now
*/
void set(T history, T now);
}
package com.yanzuoguang.util.vo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 数据库操作对象
*
* @param <T>
* @author 颜佐光
*/
public class DataDaoVo<T> {
private List<T> creates = new ArrayList<>();
private List<T> updates = new ArrayList<>();
private List<T> removes = new ArrayList<>();
private Map<String, T> mapNow = new HashMap<>();
/**
* 初始话对象
*
* @param hisitories
* @param nows
* @param keyFunc
*/
public <T> DataDaoVo<T> init(List<T> hisitories, List<T> nows, DataDaoKey<T> keyFunc) {
Map<String, T> mapHistory = new HashMap<>((hisitories.size() + nows.size()) / 2);
// 历史数据处理
for (T his : hisitories) {
String key = keyFunc.getKey(his);
T t = mapHistory.get(key);
mapHistory.put(key, t);
}
DataDaoVo<T> res = new DataDaoVo<T>();
// 返回集
for (T now : nows) {
String key = keyFunc.getKey(now);
T his = mapHistory.get(key);
if (his == null) {
res.creates.add(now);
res.mapNow.put(key, now);
} else {
keyFunc.set(his, now);
res.updates.add(his);
res.mapNow.put(key, his);
}
}
res.removes.addAll(mapHistory.values());
return res;
}
/**
* 需要创建的对象
*
* @return
*/
public List<T> getCreates() {
return creates;
}
/**
* 需要修改的对象
*
* @return
*/
public List<T> getUpdates() {
return updates;
}
/**
* 需要删除的对象
*
* @return
*/
public List<T> getRemoves() {
return removes;
}
/**
* 所有需要修改和更新的对象
*
* @return
*/
public Map<String, T> getMapNow() {
return mapNow;
}
}
......@@ -38,7 +38,7 @@ public class ExportColumn {
/**
* 宽度
*/
@ApiModelProperty(notes = "列标题,如 A.B")
@ApiModelProperty(notes = "宽度")
private short width;
public String getTitle() {
......
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