|
@@ -17,18 +17,28 @@ public class PictureReplaceAll {
|
|
|
* @author LG
|
|
|
* @Date 2023/8/16 22:52
|
|
|
*/
|
|
|
- public static void replaceAllPictureUrl(List<LinkedHashMap<String, Object>> list, String replaceKey, String oldIdKey, String newIpKey) {
|
|
|
- list.replaceAll(map -> replaceSchedulePictures(map, replaceKey, oldIdKey, newIpKey));
|
|
|
+ public static void replaceAllPictureUrl(List<LinkedHashMap<String, Object>> list, String replaceKey, String oldIpKey, String newIpKey) {
|
|
|
+ String oldIp = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(oldIpKey).getData();
|
|
|
+ String newIp = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(newIpKey).getData();
|
|
|
+ list.replaceAll(map -> replaceSchedulePictures(map, replaceKey, oldIp, newIp));
|
|
|
}
|
|
|
|
|
|
- public static LinkedHashMap<String, Object> replaceSchedulePictures(LinkedHashMap<String, Object> map, String replaceKey, String oldIdKey, String newIpKey) {
|
|
|
- String oldId = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(oldIdKey).getData();
|
|
|
- String newIp = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(newIpKey).getData();
|
|
|
- String url = Optional.ofNullable(map.get(replaceKey)).map(Object::toString).map(s -> s.replaceAll(oldId, newIp)).orElse("");
|
|
|
+ public static LinkedHashMap<String, Object> replaceSchedulePictures(LinkedHashMap<String, Object> map, String replaceKey, String oldIp, String newIp) {
|
|
|
+ String url = Optional.ofNullable(map.get(replaceKey)).map(Object::toString).map(s -> s.replaceAll(oldIp, newIp)).orElse("");
|
|
|
map.put(replaceKey, url);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ public static List<String> replacePicturesList(List<String> picturesList, String oldIdKey, String newIpKey){
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ String oldIp = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(oldIdKey).getData();
|
|
|
+ String newIp = SpringUtils.getBean(RemoteConfigService.class).remotegetConfigKey(newIpKey).getData();
|
|
|
+ picturesList.forEach(s->{
|
|
|
+ result.add(s.replaceAll(oldIp, newIp));
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static void StringToList(Map<String, Object> info){
|
|
|
if(info.containsKey("attachPaths")){
|
|
|
info.put("attachPaths", info.get("attachPaths").toString().split(","));
|