22 lines
393 B
Go
22 lines
393 B
Go
package adminfinance
|
|
|
|
import (
|
|
"github.com/redis/go-redis/v9"
|
|
"golang.org/x/sync/singleflight"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Repository struct {
|
|
db *gorm.DB
|
|
redis *redis.Client
|
|
sfGroup singleflight.Group
|
|
}
|
|
|
|
func NewRepository(db *gorm.DB, redisClient ...*redis.Client) *Repository {
|
|
repo := &Repository{db: db}
|
|
if len(redisClient) > 0 {
|
|
repo.redis = redisClient[0]
|
|
}
|
|
return repo
|
|
}
|