|
@@ -27,6 +27,8 @@ public class PropertyService extends ServiceImpl<PropertyItemDao, PropertyItem>
|
|
|
|
|
|
private static final long BASELINE_ENV_ID = 0L;
|
|
|
|
|
|
+ private static final String APP_VERSION_KEY = "com.qmth.solar.app-version";
|
|
|
+
|
|
|
@Resource
|
|
|
private EnvService envService;
|
|
|
|
|
@@ -213,10 +215,10 @@ public class PropertyService extends ServiceImpl<PropertyItemDao, PropertyItem>
|
|
|
.eq(PropertyItem::getKey, key));
|
|
|
}
|
|
|
|
|
|
- public List<PropertyItem> mergePropertyList(Long versionId, Long moduleId, Long envId) {
|
|
|
- List<PropertyItem> list = listBaseline(versionId, moduleId);
|
|
|
+ public List<PropertyItem> mergePropertyList(Version version, Long moduleId, Long envId) {
|
|
|
+ List<PropertyItem> list = listBaseline(version.getId(), moduleId);
|
|
|
//获取环境定义配置项
|
|
|
- Map<String, PropertyItem> itemMap = listPropertyItem(versionId, moduleId, envId).stream()
|
|
|
+ Map<String, PropertyItem> itemMap = listPropertyItem(version.getId(), moduleId, envId).stream()
|
|
|
.collect(Collectors.toMap(PropertyItem::getKey, Function.identity()));
|
|
|
//遍历基线
|
|
|
for (PropertyItem item : list) {
|
|
@@ -234,8 +236,23 @@ public class PropertyService extends ServiceImpl<PropertyItemDao, PropertyItem>
|
|
|
//合并新增配置项
|
|
|
if (!itemMap.isEmpty()) {
|
|
|
list.addAll(itemMap.values());
|
|
|
- list.sort(Comparator.comparing(PropertyItem::getKey));
|
|
|
}
|
|
|
+ //强制增加版本配置项,自动根据当前version填充
|
|
|
+ boolean hasVersion = false;
|
|
|
+ for (PropertyItem item : list) {
|
|
|
+ if (item.getKey().equals(APP_VERSION_KEY)) {
|
|
|
+ item.setValue(version.getName());
|
|
|
+ hasVersion = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!hasVersion) {
|
|
|
+ PropertyItem item = new PropertyItem();
|
|
|
+ item.setKey(APP_VERSION_KEY);
|
|
|
+ item.setValue(version.getName());
|
|
|
+ list.add(item);
|
|
|
+ }
|
|
|
+ list.sort(Comparator.comparing(PropertyItem::getKey));
|
|
|
return list;
|
|
|
}
|
|
|
}
|