mirror of
https://github.com/tiennm99/store-scraper-bot-java.git
synced 2026-05-14 05:53:04 +00:00
feat(repo): cleanup
This commit is contained in:
@@ -3,10 +3,8 @@ package com.miti99.storescraperbot.model;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Admin extends AbstractModel {
|
||||
Set<Long> groups = new HashSet<>();
|
||||
final Set<Long> groups = new HashSet<>();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import org.bson.Document;
|
||||
*/
|
||||
@Log4j2
|
||||
public abstract class AbstractRepository<K, V extends AbstractModel> {
|
||||
protected static final String SEPARATOR = "_";
|
||||
// protected final Class<K> classK = getKeyClass();
|
||||
protected final Class<V> classV = getDataClass();
|
||||
protected final String collectionName;
|
||||
protected final MongoCollection<Document> collection;
|
||||
@@ -41,11 +39,6 @@ public abstract class AbstractRepository<K, V extends AbstractModel> {
|
||||
collection = MongoDBUtil.DATABASE.getCollection(collectionName, Document.class);
|
||||
}
|
||||
|
||||
// protected Class<K> getKeyClass() {
|
||||
// return (Class<K>)
|
||||
// ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
// }
|
||||
|
||||
/**
|
||||
* Lấy ra class của V. Khi tạo 1 abstract class extends AbstractRepository mà không phải final thì
|
||||
* sẽ cần override hàm này phù hợp
|
||||
|
||||
@@ -15,9 +15,6 @@ 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)
|
||||
@@ -28,15 +25,10 @@ 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