From 1a0adaa97bc6970599373bc38d2dc3a9cde8646c Mon Sep 17 00:00:00 2001 From: wangyu <727842003@qq.com> Date: Tue, 2 Jul 2024 18:03:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B9=B1=E7=A0=81=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E9=81=97=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convert/FullMappingR2dbcConverter.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/flyfish-data/flyfish-data-r2dbc/src/main/java/com/flyfish/framework/r2dbc/config/convert/FullMappingR2dbcConverter.java b/flyfish-data/flyfish-data-r2dbc/src/main/java/com/flyfish/framework/r2dbc/config/convert/FullMappingR2dbcConverter.java index 34daad6..f3fd29c 100644 --- a/flyfish-data/flyfish-data-r2dbc/src/main/java/com/flyfish/framework/r2dbc/config/convert/FullMappingR2dbcConverter.java +++ b/flyfish-data/flyfish-data-r2dbc/src/main/java/com/flyfish/framework/r2dbc/config/convert/FullMappingR2dbcConverter.java @@ -115,6 +115,23 @@ public class FullMappingR2dbcConverter extends MappingR2dbcConverter { } + /** + * Returns given object as {@link Collection}. Will return the {@link Collection} as is if the source is a + * {@link Collection} already, will convert an array into a {@link Collection} or simply create a single element + * collection for everything else. + * + * @param source + * @return + */ + private static Collection asCollection(Object source) { + + if (source instanceof Collection) { + return (Collection) source; + } + + return source.getClass().isArray() ? CollectionUtils.arrayToList(source) : Collections.singleton(source); + } + /** * Checks whether we have a custom conversion registered for the given value into an arbitrary simple type. Returns * the converted value if so. If not, we perform special enum handling or simply return the value as is. @@ -145,6 +162,10 @@ public class FullMappingR2dbcConverter extends MappingR2dbcConverter { return Enum.class.isAssignableFrom(value.getClass()) ? ((Enum) value).name() : value; } + private Object writeNestedObject(@NonNull Object object) { + return JacksonUtil.toJson(object).orElse(null); + } + private Class getPotentiallyConvertedSimpleNullType(Class type) { Optional> customTarget = getConversions().getCustomWriteTarget(type);