|
@@ -15,7 +15,10 @@ import javax.annotation.Resource;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -102,24 +105,33 @@ public class PropertyService extends ServiceImpl<PropertyItemDao, PropertyItem>
|
|
|
*/
|
|
|
private void resetEnvProperty(App app, Version version, Module module, Env env, Version inheritVersion,
|
|
|
Map<String, PropertyItem> baseMap) {
|
|
|
+ List<PropertyItem> currentList = listPropertyItem(app.getId(), version.getId(), module.getId(), env.getId());
|
|
|
propertyItemDao.delete(new LambdaUpdateWrapper<PropertyItem>().eq(PropertyItem::getAppId, app.getId())
|
|
|
.eq(PropertyItem::getVersionId, version.getId()).eq(PropertyItem::getModuleId, module.getId())
|
|
|
.eq(PropertyItem::getEnvId, env.getId()));
|
|
|
+ long time = System.currentTimeMillis();
|
|
|
+ Map<String, PropertyItem> saveMap = new HashMap<>();
|
|
|
+ for (PropertyItem item : currentList) {
|
|
|
+ if (accept(item, baseMap)) {
|
|
|
+ item.setVersionId(version.getId());
|
|
|
+ item.setCreateTime(time);
|
|
|
+ item.setUpdateTime(time);
|
|
|
+ saveMap.put(item.getKey(), item);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (inheritVersion != null) {
|
|
|
- long time = System.currentTimeMillis();
|
|
|
List<PropertyItem> inheritList = listPropertyItem(app.getId(), inheritVersion.getId(), module.getId(),
|
|
|
env.getId());
|
|
|
- List<PropertyItem> saveList = new LinkedList<>();
|
|
|
for (PropertyItem item : inheritList) {
|
|
|
- if (accept(item, baseMap)) {
|
|
|
+ if (!saveMap.containsKey(item.getKey()) && accept(item, baseMap)) {
|
|
|
item.setVersionId(version.getId());
|
|
|
item.setCreateTime(time);
|
|
|
item.setUpdateTime(time);
|
|
|
- saveList.add(item);
|
|
|
+ saveMap.put(item.getKey(), item);
|
|
|
}
|
|
|
}
|
|
|
- saveBatch(saveList);
|
|
|
}
|
|
|
+ saveBatch(saveMap.values());
|
|
|
}
|
|
|
|
|
|
/**
|