From 1cad14bca191807e18705c3a5526eda8151be439 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 14 四月 2025 23:10:22 +0800
Subject: [PATCH] 批量审核和图片保存bug

---
 ycl-platform/src/main/java/com/ycl/config/feign/UnderlineQueryEncoder.java |  117 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 58 insertions(+), 59 deletions(-)

diff --git a/ycl-platform/src/main/java/com/ycl/config/feign/UnderlineQueryEncoder.java b/ycl-platform/src/main/java/com/ycl/config/feign/UnderlineQueryEncoder.java
index 2a17195..bc55c2e 100644
--- a/ycl-platform/src/main/java/com/ycl/config/feign/UnderlineQueryEncoder.java
+++ b/ycl-platform/src/main/java/com/ycl/config/feign/UnderlineQueryEncoder.java
@@ -1,9 +1,9 @@
 package com.ycl.config.feign;
 
 import com.ycl.utils.StringUtils;
-//import feign.Param;
-//import feign.QueryMapEncoder;
-//import feign.codec.EncodeException;
+import feign.Param;
+import feign.QueryMapEncoder;
+import feign.codec.EncodeException;
 
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
@@ -12,60 +12,59 @@
 import java.lang.reflect.Method;
 import java.util.*;
 
-public class UnderlineQueryEncoder{
-//        implements QueryMapEncoder {
-//    private final Map<Class<?>, ObjectParamMetadata> classToMetadata =
-//            new HashMap();
-//
-//    @Override
-//    public Map<String, Object> encode(Object object) throws EncodeException {
-//        try {
-//            ObjectParamMetadata metadata = getMetadata(object.getClass());
-//            Map<String, Object> propertyNameToValue = new HashMap<String, Object>();
-//            for (PropertyDescriptor pd : metadata.objectProperties) {
-//                Method method = pd.getReadMethod();
-//                Object value = method.invoke(object);
-//                if (value != null && value != object) {
-//                    Param alias = method.getAnnotation(Param.class);
-//                    String name = alias != null ? alias.value() : pd.getName();
-//                    propertyNameToValue.put(StringUtils.camelToUnderlineLowerCase(name), value);
-//                }
-//            }
-//            return propertyNameToValue;
-//        } catch (IllegalAccessException | IntrospectionException | InvocationTargetException e) {
-//            throw new EncodeException("Failure encoding object into query map", e);
-//        }
-//    }
-//
-//    private ObjectParamMetadata getMetadata(Class<?> objectType) throws IntrospectionException {
-//        ObjectParamMetadata metadata = classToMetadata.get(objectType);
-//        if (metadata == null) {
-//            metadata = ObjectParamMetadata.parseObjectType(objectType);
-//            classToMetadata.put(objectType, metadata);
-//        }
-//        return metadata;
-//    }
-//
-//    private static class ObjectParamMetadata {
-//
-//        private final List<PropertyDescriptor> objectProperties;
-//
-//        private ObjectParamMetadata(List<PropertyDescriptor> objectProperties) {
-//            this.objectProperties = Collections.unmodifiableList(objectProperties);
-//        }
-//
-//        private static ObjectParamMetadata parseObjectType(Class<?> type)
-//                throws IntrospectionException {
-//            List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
-//
-//            for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) {
-//                boolean isGetterMethod = pd.getReadMethod() != null && !"class".equals(pd.getName());
-//                if (isGetterMethod) {
-//                    properties.add(pd);
-//                }
-//            }
-//
-//            return new ObjectParamMetadata(properties);
-//        }
-//    }
+public class UnderlineQueryEncoder implements QueryMapEncoder {
+    private final Map<Class<?>, ObjectParamMetadata> classToMetadata =
+            new HashMap();
+
+    @Override
+    public Map<String, Object> encode(Object object) throws EncodeException {
+        try {
+            ObjectParamMetadata metadata = getMetadata(object.getClass());
+            Map<String, Object> propertyNameToValue = new HashMap<String, Object>();
+            for (PropertyDescriptor pd : metadata.objectProperties) {
+                Method method = pd.getReadMethod();
+                Object value = method.invoke(object);
+                if (value != null && value != object) {
+                    Param alias = method.getAnnotation(Param.class);
+                    String name = alias != null ? alias.value() : pd.getName();
+                    propertyNameToValue.put(StringUtils.camelToUnderlineLowerCase(name), value);
+                }
+            }
+            return propertyNameToValue;
+        } catch (IllegalAccessException | IntrospectionException | InvocationTargetException e) {
+            throw new EncodeException("Failure encoding object into query map", e);
+        }
+    }
+
+    private ObjectParamMetadata getMetadata(Class<?> objectType) throws IntrospectionException {
+        ObjectParamMetadata metadata = classToMetadata.get(objectType);
+        if (metadata == null) {
+            metadata = ObjectParamMetadata.parseObjectType(objectType);
+            classToMetadata.put(objectType, metadata);
+        }
+        return metadata;
+    }
+
+    private static class ObjectParamMetadata {
+
+        private final List<PropertyDescriptor> objectProperties;
+
+        private ObjectParamMetadata(List<PropertyDescriptor> objectProperties) {
+            this.objectProperties = Collections.unmodifiableList(objectProperties);
+        }
+
+        private static ObjectParamMetadata parseObjectType(Class<?> type)
+                throws IntrospectionException {
+            List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
+
+            for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) {
+                boolean isGetterMethod = pd.getReadMethod() != null && !"class".equals(pd.getName());
+                if (isGetterMethod) {
+                    properties.add(pd);
+                }
+            }
+
+            return new ObjectParamMetadata(properties);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0