import
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package repository
|
||||
|
||||
import "log/slog"
|
||||
|
||||
// NotificationDB — интерфейс базы данных, который нужен NotificationRepo.
|
||||
type NotificationDB interface {
|
||||
Query(query string) error
|
||||
Exec(query string) error
|
||||
BulkInsert(query string, args ...any) error
|
||||
}
|
||||
|
||||
// NotificationRepo — интерфейс репозитория уведомлений.
|
||||
type NotificationRepo interface{}
|
||||
|
||||
// notificationRepo — конкретная реализация, скрыта от внешних пакетов.
|
||||
type notificationRepo struct {
|
||||
db NotificationDB
|
||||
}
|
||||
|
||||
// NewNotificationRepo создаёт репозиторий уведомлений.
|
||||
func NewNotificationRepo(db NotificationDB) NotificationRepo {
|
||||
slog.Info("репозиторий уведомлений создан")
|
||||
return ¬ificationRepo{db: db}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package repository
|
||||
|
||||
import "log/slog"
|
||||
|
||||
// SessionDB — интерфейс базы данных, который нужен SessionRepo.
|
||||
type SessionDB interface {
|
||||
Query(query string) error
|
||||
Exec(query string) error
|
||||
BeginTx() error
|
||||
}
|
||||
|
||||
// SessionCache — интерфейс кэша, который нужен SessionRepo.
|
||||
type SessionCache interface {
|
||||
Get(key string) (string, error)
|
||||
Set(key, value string) error
|
||||
}
|
||||
|
||||
// SessionRepo — интерфейс репозитория сессий.
|
||||
type SessionRepo interface{}
|
||||
|
||||
// sessionRepo — конкретная реализация, скрыта от внешних пакетов.
|
||||
type sessionRepo struct {
|
||||
db SessionDB
|
||||
cache SessionCache
|
||||
}
|
||||
|
||||
// NewSessionRepo создаёт репозиторий сессий.
|
||||
func NewSessionRepo(db SessionDB, cache SessionCache) SessionRepo {
|
||||
slog.Info("репозиторий сессий создан")
|
||||
return &sessionRepo{db: db, cache: cache}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package repository
|
||||
|
||||
import "log/slog"
|
||||
|
||||
// UserDB — интерфейс базы данных, который нужен UserRepo.
|
||||
type UserDB interface {
|
||||
Query(query string) error
|
||||
QueryRow(query string) error
|
||||
Exec(query string) error
|
||||
}
|
||||
|
||||
// UserRepo — интерфейс репозитория пользователей.
|
||||
type UserRepo interface{}
|
||||
|
||||
// userRepo — конкретная реализация, скрыта от внешних пакетов.
|
||||
type userRepo struct {
|
||||
db UserDB
|
||||
}
|
||||
|
||||
// NewUserRepo создаёт репозиторий пользователей.
|
||||
func NewUserRepo(db UserDB) UserRepo {
|
||||
slog.Info("репозиторий пользователей создан")
|
||||
return &userRepo{db: db}
|
||||
}
|
||||
Reference in New Issue
Block a user