repositories package переименован в interfaces

This commit is contained in:
ErickSkrauch 2017-08-18 00:50:23 +03:00
parent 78917a70d3
commit b1dbee2310
8 changed files with 30 additions and 31 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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
}

View File

@ -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")
}

View File

@ -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)
}

View File

@ -1,7 +0,0 @@
package repositories
import "elyby/minecraft-skinsystem/model"
type CapesRepository interface {
FindByUsername(username string) (model.Cape, error)
}

View File

@ -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,

View File

@ -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
}