-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chat2db:main' into main
- Loading branch information
Showing
27 changed files
with
2,091 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
chat2db-server/chat2db-spi/src/main/java/ai/chat2db/spi/sql/DocumentUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ai.chat2db.spi.sql; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.commons.lang3.ClassUtils; | ||
|
||
/** | ||
* @author luojun | ||
* @version 1.0 | ||
* @description: 接口定义 | ||
* @date 2024/5/31 19:05 | ||
**/ | ||
public class DocumentUtils { | ||
|
||
public static LinkedHashMap<String, Object> convertToMap(Object obj) { | ||
LinkedHashMap<String, Object> map = new LinkedHashMap<>(); | ||
if (obj == null) { | ||
return map; | ||
} | ||
if (ClassUtils.isPrimitiveOrWrapper(obj.getClass()) || String.class.equals(obj.getClass())) { | ||
map.put("result", obj); | ||
return map; | ||
} | ||
for (Map.Entry<String, Object> entry : ((Map<String, Object>) obj).entrySet()) { | ||
Object value = entry.getValue(); | ||
if (value == null) { | ||
map.put(entry.getKey(), null); | ||
} else if (ClassUtils.isPrimitiveOrWrapper(value.getClass()) || String.class.equals(value.getClass())) { | ||
map.put(entry.getKey(), value); | ||
} else if (entry.getValue() instanceof Map) { | ||
LinkedHashMap<String, Object> mmp = convertToMap(entry.getValue()); | ||
map.put(entry.getKey(), mmp); | ||
} else { | ||
map.put(entry.getKey(), entry.getValue().toString()); | ||
} | ||
} | ||
return map; | ||
} | ||
} |
Oops, something went wrong.