mirror of
https://github.com/tiennm99/store-scraper-bot-java.git
synced 2026-05-14 09:53:03 +00:00
feat(codec): try to auto handle (de)serialize
This commit is contained in:
@@ -8,4 +8,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
public class AppleApp extends AbstractModel<String> {
|
||||
AppleAppResponse app;
|
||||
long millis; // TODO: handle expire
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ import lombok.Setter;
|
||||
@Setter
|
||||
public class GoogleApp extends AbstractModel<String> {
|
||||
GoogleAppResponse app;
|
||||
long millis; // TODO: handle expire
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.bson.Document;
|
||||
import org.bson.codecs.configuration.CodecRegistries;
|
||||
import org.bson.codecs.configuration.CodecRegistry;
|
||||
import org.bson.codecs.pojo.PojoCodecProvider;
|
||||
|
||||
@Log4j2
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@@ -25,10 +28,15 @@ public class MongoDBUtil {
|
||||
static {
|
||||
var serverApi = ServerApi.builder().version(ServerApiVersion.V1).build();
|
||||
var connectionString = new ConnectionString(MONGODB_CONNECTION_STRING);
|
||||
var pojoCodecRegistry =
|
||||
CodecRegistries.fromRegistries(
|
||||
MongoClientSettings.getDefaultCodecRegistry(),
|
||||
CodecRegistries.fromProviders(PojoCodecProvider.builder().automatic(true).build()));
|
||||
var settings =
|
||||
MongoClientSettings.builder()
|
||||
.applyConnectionString(connectionString)
|
||||
.serverApi(serverApi)
|
||||
.codecRegistry(pojoCodecRegistry)
|
||||
.build();
|
||||
MONGO_CLIENT = MongoClients.create(settings);
|
||||
var databaseName =
|
||||
|
||||
Reference in New Issue
Block a user