use of com.github.yiuman.citrus.mda.entity.history.HistoryTable in project citrus by Yiuman.
the class HistoricConverter method convert.
@Override
public HistoryTable convert(Table table) {
HistoryTable historyTable = Converter.super.convert(table);
historyTable.setUuid(null);
historyTable.setTableUuid(table.getUuid());
List<Column> columnList = TableRelUtils.getTableRelInfos(table.getUuid(), Column.class);
if (!CollectionUtils.isEmpty(columnList)) {
historyTable.setColumns(columnList.parallelStream().map(LambdaUtils.functionWrapper(column -> ConvertUtils.convert(HistoryColumn.class, column))).collect(Collectors.toList()));
}
List<Indexes> indexesList = TableRelUtils.getTableRelInfos(table.getUuid(), Indexes.class);
if (!CollectionUtils.isEmpty(indexesList)) {
historyTable.setIndexes(indexesList.parallelStream().map(LambdaUtils.functionWrapper(indexes -> ConvertUtils.convert(HistoryIndexes.class, indexes))).collect(Collectors.toList()));
}
return historyTable;
}
use of com.github.yiuman.citrus.mda.entity.history.HistoryTable in project citrus by Yiuman.
the class TableEntityServiceImpl method beforeSave.
@Override
public boolean beforeSave(Table entity) throws Exception {
// 实体变更前保存一份历史记录
if (StringUtils.isBlank(entity.getUuid())) {
Table table = get(entity.getUuid());
if (Objects.nonNull(table)) {
CrudMapper<HistoryTable> historyTableCrudMapper = getHistoryTableCrudMapper();
HistoryTable historyTable = entity2History(table);
historyTableCrudMapper.saveEntity(historyTable);
TableRelUtils.saveTableRelInfos(historyTable.getColumns(), historyTable.getUuid());
TableRelUtils.saveTableRelInfos(historyTable.getIndexes(), historyTable.getUuid());
}
}
return true;
}
Aggregations