Quellcode durchsuchen

修复bug,资源详情图片路径返回结果转换为String的bug

Wang-Xiao-Ran vor 1 Jahr
Ursprung
Commit
2f694ed9b9

+ 9 - 2
src/main/java/com/sooka/sponest/mobile/appbigdata/controller/AppBigDataCountController.java

@@ -77,8 +77,15 @@ public class AppBigDataCountController extends VisuBaseService {
     public AjaxResult getResourcePointById(@RequestBody VisualBO vb) {
         R resultData = middlewareService.getResourcePointById(vb.getId(), vb.getType());
         if (HttpStatus.SUCCESS == resultData.getCode()) {
-            LinkedHashMap<String, Object> data = (LinkedHashMap<String, Object>) resultData.getData();
-            return AjaxResult.success(PictureReplaceAll.replaceSchedulePictures(data,"pictures", "fileUrl", "appUrl"));
+            Map<String, Object> data = (Map<String, Object>) resultData.getData();
+            if(data.containsKey("pictures")){
+                List<String> pictures = (List<String>) data.get("pictures");
+                if(!pictures.isEmpty()){
+                    List<String> strList = PictureReplaceAll.replacePicturesList(pictures, "fileUrl", "appUrl");
+                    data.put("pictures", strList);
+                }
+            }
+            return AjaxResult.success(data);
         } else {
             return AjaxResult.error(resultData.getMsg());
         }

+ 16 - 6
src/main/java/com/sooka/sponest/mobile/utils/PictureReplaceAll.java

@@ -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(","));