mirror of
https://github.com/elyby/chrly.git
synced 2024-11-26 16:51:59 +05:30
Entities в model, repositories в repositories
This commit is contained in:
parent
11a7570f51
commit
428bedf301
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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: нужно абстрагироваться в отдельный файл с инфой о скине
|
||||
}
|
||||
|
@ -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
7
repositories/capes.go
Normal 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
8
repositories/skins.go
Normal 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)
|
||||
}
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user