mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 13:40:11 +05:30
repositories package переименован в interfaces
This commit is contained in:
parent
78917a70d3
commit
b1dbee2310
@ -9,17 +9,17 @@ import (
|
||||
|
||||
"github.com/mono83/slf/wd"
|
||||
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
"elyby/minecraft-skinsystem/ui"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ListenSpec string
|
||||
|
||||
SkinsRepo repositories.SkinsRepository
|
||||
CapesRepo repositories.CapesRepository
|
||||
Logger wd.Watchdog
|
||||
UI ui.Config
|
||||
SkinsRepo interfaces.SkinsRepository
|
||||
CapesRepo interfaces.CapesRepository
|
||||
Logger wd.Watchdog
|
||||
UI ui.Config
|
||||
}
|
||||
|
||||
func Run(cfg *Config) error {
|
||||
|
@ -3,7 +3,7 @@ package db
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
)
|
||||
|
||||
type StorageFactory struct {
|
||||
@ -11,8 +11,8 @@ type StorageFactory struct {
|
||||
}
|
||||
|
||||
type RepositoriesCreator interface {
|
||||
CreateSkinsRepository() (repositories.SkinsRepository, error)
|
||||
CreateCapesRepository() (repositories.CapesRepository, error)
|
||||
CreateSkinsRepository() (interfaces.SkinsRepository, error)
|
||||
CreateCapesRepository() (interfaces.CapesRepository, error)
|
||||
}
|
||||
|
||||
func (factory *StorageFactory) CreateFactory(backend string) RepositoriesCreator {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"elyby/minecraft-skinsystem/model"
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
)
|
||||
|
||||
type FilesystemFactory struct {
|
||||
@ -14,11 +14,11 @@ type FilesystemFactory struct {
|
||||
CapesDirName string
|
||||
}
|
||||
|
||||
func (f FilesystemFactory) CreateSkinsRepository() (repositories.SkinsRepository, error) {
|
||||
func (f FilesystemFactory) CreateSkinsRepository() (interfaces.SkinsRepository, error) {
|
||||
panic("skins repository not supported for this storage type")
|
||||
}
|
||||
|
||||
func (f FilesystemFactory) CreateCapesRepository() (repositories.CapesRepository, error) {
|
||||
func (f FilesystemFactory) CreateCapesRepository() (interfaces.CapesRepository, error) {
|
||||
if err := f.validateFactoryConfig(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/mediocregopher/radix.v2/util"
|
||||
|
||||
"elyby/minecraft-skinsystem/model"
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
)
|
||||
|
||||
type RedisFactory struct {
|
||||
@ -25,7 +25,7 @@ type RedisFactory struct {
|
||||
connection util.Cmder
|
||||
}
|
||||
|
||||
func (f RedisFactory) CreateSkinsRepository() (repositories.SkinsRepository, error) {
|
||||
func (f RedisFactory) CreateSkinsRepository() (interfaces.SkinsRepository, error) {
|
||||
connection, err := f.getConnection()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -34,7 +34,7 @@ func (f RedisFactory) CreateSkinsRepository() (repositories.SkinsRepository, err
|
||||
return &redisDb{connection}, nil
|
||||
}
|
||||
|
||||
func (f RedisFactory) CreateCapesRepository() (repositories.CapesRepository, error) {
|
||||
func (f RedisFactory) CreateCapesRepository() (interfaces.CapesRepository, error) {
|
||||
panic("capes repository not supported for this storage type")
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,15 @@
|
||||
package repositories
|
||||
package interfaces
|
||||
|
||||
import "elyby/minecraft-skinsystem/model"
|
||||
import (
|
||||
"elyby/minecraft-skinsystem/model"
|
||||
)
|
||||
|
||||
type SkinsRepository interface {
|
||||
FindByUsername(username string) (*model.Skin, error)
|
||||
FindByUserId(id int) (*model.Skin, error)
|
||||
Save(skin *model.Skin) error
|
||||
}
|
||||
|
||||
type CapesRepository interface {
|
||||
FindByUsername(username string) (model.Cape, error)
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package repositories
|
||||
|
||||
import "elyby/minecraft-skinsystem/model"
|
||||
|
||||
type CapesRepository interface {
|
||||
FindByUsername(username string) (model.Cape, error)
|
||||
}
|
@ -2,19 +2,19 @@ package ui
|
||||
|
||||
import (
|
||||
"github.com/mono83/slf/wd"
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
)
|
||||
|
||||
type uiService struct {
|
||||
logger wd.Watchdog
|
||||
skinsRepo repositories.SkinsRepository
|
||||
capesRepo repositories.CapesRepository
|
||||
logger wd.Watchdog
|
||||
skinsRepo interfaces.SkinsRepository
|
||||
capesRepo interfaces.CapesRepository
|
||||
}
|
||||
|
||||
func NewUiService(
|
||||
logger wd.Watchdog,
|
||||
skinsRepo repositories.SkinsRepository,
|
||||
capesRepo repositories.CapesRepository,
|
||||
skinsRepo interfaces.SkinsRepository,
|
||||
capesRepo interfaces.CapesRepository,
|
||||
) (*uiService, error) {
|
||||
return &uiService{
|
||||
logger: logger,
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
"github.com/streadway/amqp"
|
||||
|
||||
"elyby/minecraft-skinsystem/model"
|
||||
"elyby/minecraft-skinsystem/repositories"
|
||||
"elyby/minecraft-skinsystem/interfaces"
|
||||
)
|
||||
|
||||
type Services struct {
|
||||
Channel *amqp.Channel
|
||||
SkinsRepo repositories.SkinsRepository
|
||||
SkinsRepo interfaces.SkinsRepository
|
||||
Logger wd.Watchdog
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user