File tree Expand file tree Collapse file tree
src/main/java/ai/chat2db/spi/sql Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8080 <version >1.19.0</version > <!-- Make sure to use the latest version -->
8181 </dependency >
8282
83- <!-- https://mvnrepository.com/artifact/org.mongodb/bson -->
84- <dependency >
85- <groupId >org.mongodb</groupId >
86- <artifactId >bson</artifactId >
87- </dependency >
8883 <dependency >
8984 <groupId >org.antlr</groupId >
9085 <artifactId >antlr4</artifactId >
Original file line number Diff line number Diff line change 1+ package ai .chat2db .spi .sql ;
2+
3+ import java .util .LinkedHashMap ;
4+ import java .util .Map ;
5+
6+ import com .alibaba .fastjson2 .JSON ;
7+ import com .alibaba .fastjson2 .JSONObject ;
8+
9+ /**
10+ * @author luojun
11+ * @version 1.0
12+ * @description: 接口定义
13+ * @date 2024/5/31 19:05
14+ **/
15+ public class DocumentUtils {
16+
17+ public static LinkedHashMap <String , Object > convertToMap (Object obj ) {
18+ LinkedHashMap <String , Object > map = new LinkedHashMap <>();
19+ if (obj != null ) {
20+ String json = JSON .toJSONString (obj );
21+ JSONObject jsonObject = JSON .parseObject (json );
22+ JSONObject m = jsonObject .getJSONObject ("documentAsMap" );
23+ if (m != null ) {
24+ for (Map .Entry <String , Object > entry : m .entrySet ()) {
25+ map .put (entry .getKey (), entry .getValue ());
26+ }
27+ }
28+ }
29+ return map ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1- package ai .chat2db .spi .sql ;
2-
3- import org .bson .json .Converter ;
4- import org .bson .json .StrictJsonWriter ;
5- import org .bson .types .ObjectId ;
6-
7- public class MongExtendedJsonObjectIdConverter implements Converter <ObjectId > {
8- @ Override
9- public void convert (final ObjectId value , final StrictJsonWriter writer ) {
10- writer .writeStartObject ();
11- writer .writeString ("" , value .toHexString ());
12- writer .writeEndObject ();
13- }
14- }
1+ // package ai.chat2db.spi.sql;
2+ //
3+ // import org.bson.json.Converter;
4+ // import org.bson.json.StrictJsonWriter;
5+ // import org.bson.types.ObjectId;
6+ //
7+ // public class MongExtendedJsonObjectIdConverter implements Converter<ObjectId> {
8+ // @Override
9+ // public void convert(final ObjectId value, final StrictJsonWriter writer) {
10+ // writer.writeStartObject();
11+ // writer.writeString("", value.toHexString());
12+ // writer.writeEndObject();
13+ // }
14+ // }
You can’t perform that action at this time.
0 commit comments