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