Entities в model, repositories в repositories

This commit is contained in:
ErickSkrauch 2017-08-09 19:19:46 +03:00
parent 11a7570f51
commit 428bedf301
10 changed files with 38 additions and 28 deletions

View File

@ -3,7 +3,6 @@ package daemon
import (
"net"
"elyby/minecraft-skinsystem/model"
"elyby/minecraft-skinsystem/ui"
"fmt"
@ -13,13 +12,14 @@ import (
"syscall"
"github.com/mono83/slf/wd"
"elyby/minecraft-skinsystem/repositories"
)
type Config struct {
ListenSpec string
SkinsRepo model.SkinsRepository
CapesRepo model.CapesRepository
SkinsRepo repositories.SkinsRepository
CapesRepo repositories.CapesRepository
Logger wd.Watchdog
UI ui.Config
}

View File

@ -1,7 +1,9 @@
package capes
import "elyby/minecraft-skinsystem/model"
import (
"elyby/minecraft-skinsystem/repositories"
)
type CapesRepositoryCreator interface {
Create() (model.CapesRepository, error)
Create() (repositories.CapesRepository, error)
}

View File

@ -1,11 +1,13 @@
package files
import "elyby/minecraft-skinsystem/model"
import (
"elyby/minecraft-skinsystem/repositories"
)
type FilesystemCapesFactory struct {
StoragePath string
}
func (cfg *FilesystemCapesFactory) Create() (model.CapesRepository, error) {
func (cfg *FilesystemCapesFactory) Create() (repositories.CapesRepository, error) {
return &filesDb{path: cfg.StoragePath}, nil
}

View File

@ -1,7 +1,9 @@
package skins
import "elyby/minecraft-skinsystem/model"
import (
"elyby/minecraft-skinsystem/repositories"
)
type SkinsRepositoryCreator interface {
Create() (model.SkinsRepository, error)
Create() (repositories.SkinsRepository, error)
}

View File

@ -1,8 +1,7 @@
package redis
import (
"elyby/minecraft-skinsystem/model"
"elyby/minecraft-skinsystem/repositories"
"github.com/mediocregopher/radix.v2/pool"
)
@ -11,7 +10,7 @@ type RedisSkinsFactory struct {
PollSize int
}
func (cfg *RedisSkinsFactory) Create() (model.SkinsRepository, error) {
func (cfg *RedisSkinsFactory) Create() (repositories.SkinsRepository, error) {
conn, err := pool.New("tcp", cfg.Addr, cfg.PollSize)
if err != nil {
return nil, err

View File

@ -3,9 +3,5 @@ package model
import "os"
type Cape struct {
File *os.File
}
type CapesRepository interface {
FindByUsername(username string) (Cape, error)
File *os.File // TODO: нужно абстрагироваться в отдельный файл с инфой о скине
}

View File

@ -13,8 +13,3 @@ type Skin struct {
MojangSignature string `json:"mojangSignature"`
OldUsername string
}
type SkinsRepository interface {
FindByUsername(username string) (Skin, error)
FindByUserId(id int) (Skin, error)
}

7
repositories/capes.go Normal file
View File

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

8
repositories/skins.go Normal file
View File

@ -0,0 +1,8 @@
package repositories
import "elyby/minecraft-skinsystem/model"
type SkinsRepository interface {
FindByUsername(username string) (model.Skin, error)
FindByUserId(id int) (model.Skin, error)
}

View File

@ -1,21 +1,20 @@
package ui
import (
"elyby/minecraft-skinsystem/model"
"github.com/mono83/slf/wd"
"elyby/minecraft-skinsystem/repositories"
)
type uiService struct {
logger wd.Watchdog
skinsRepo model.SkinsRepository
capesRepo model.CapesRepository
skinsRepo repositories.SkinsRepository
capesRepo repositories.CapesRepository
}
func NewUiService(
logger wd.Watchdog,
skinsRepo model.SkinsRepository,
capesRepo model.CapesRepository,
skinsRepo repositories.SkinsRepository,
capesRepo repositories.CapesRepository,
) (*uiService, error) {
return &uiService{
logger: logger,