mirror of
https://github.com/elyby/chrly.git
synced 2024-12-02 11:40:56 +05:30
Entities в model, repositories в repositories
This commit is contained in:
parent
11a7570f51
commit
428bedf301
@ -3,7 +3,6 @@ package daemon
|
|||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"elyby/minecraft-skinsystem/model"
|
|
||||||
"elyby/minecraft-skinsystem/ui"
|
"elyby/minecraft-skinsystem/ui"
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -13,13 +12,14 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/mono83/slf/wd"
|
"github.com/mono83/slf/wd"
|
||||||
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
ListenSpec string
|
ListenSpec string
|
||||||
|
|
||||||
SkinsRepo model.SkinsRepository
|
SkinsRepo repositories.SkinsRepository
|
||||||
CapesRepo model.CapesRepository
|
CapesRepo repositories.CapesRepository
|
||||||
Logger wd.Watchdog
|
Logger wd.Watchdog
|
||||||
UI ui.Config
|
UI ui.Config
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package capes
|
package capes
|
||||||
|
|
||||||
import "elyby/minecraft-skinsystem/model"
|
import (
|
||||||
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
|
)
|
||||||
|
|
||||||
type CapesRepositoryCreator interface {
|
type CapesRepositoryCreator interface {
|
||||||
Create() (model.CapesRepository, error)
|
Create() (repositories.CapesRepository, error)
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package files
|
package files
|
||||||
|
|
||||||
import "elyby/minecraft-skinsystem/model"
|
import (
|
||||||
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
|
)
|
||||||
|
|
||||||
type FilesystemCapesFactory struct {
|
type FilesystemCapesFactory struct {
|
||||||
StoragePath string
|
StoragePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cfg *FilesystemCapesFactory) Create() (model.CapesRepository, error) {
|
func (cfg *FilesystemCapesFactory) Create() (repositories.CapesRepository, error) {
|
||||||
return &filesDb{path: cfg.StoragePath}, nil
|
return &filesDb{path: cfg.StoragePath}, nil
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package skins
|
package skins
|
||||||
|
|
||||||
import "elyby/minecraft-skinsystem/model"
|
import (
|
||||||
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
|
)
|
||||||
|
|
||||||
type SkinsRepositoryCreator interface {
|
type SkinsRepositoryCreator interface {
|
||||||
Create() (model.SkinsRepository, error)
|
Create() (repositories.SkinsRepository, error)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"elyby/minecraft-skinsystem/model"
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
|
|
||||||
"github.com/mediocregopher/radix.v2/pool"
|
"github.com/mediocregopher/radix.v2/pool"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,7 +10,7 @@ type RedisSkinsFactory struct {
|
|||||||
PollSize int
|
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)
|
conn, err := pool.New("tcp", cfg.Addr, cfg.PollSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -3,9 +3,5 @@ package model
|
|||||||
import "os"
|
import "os"
|
||||||
|
|
||||||
type Cape struct {
|
type Cape struct {
|
||||||
File *os.File
|
File *os.File // TODO: нужно абстрагироваться в отдельный файл с инфой о скине
|
||||||
}
|
|
||||||
|
|
||||||
type CapesRepository interface {
|
|
||||||
FindByUsername(username string) (Cape, error)
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,3 @@ type Skin struct {
|
|||||||
MojangSignature string `json:"mojangSignature"`
|
MojangSignature string `json:"mojangSignature"`
|
||||||
OldUsername string
|
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
|
package ui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"elyby/minecraft-skinsystem/model"
|
|
||||||
|
|
||||||
"github.com/mono83/slf/wd"
|
"github.com/mono83/slf/wd"
|
||||||
|
"elyby/minecraft-skinsystem/repositories"
|
||||||
)
|
)
|
||||||
|
|
||||||
type uiService struct {
|
type uiService struct {
|
||||||
logger wd.Watchdog
|
logger wd.Watchdog
|
||||||
skinsRepo model.SkinsRepository
|
skinsRepo repositories.SkinsRepository
|
||||||
capesRepo model.CapesRepository
|
capesRepo repositories.CapesRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUiService(
|
func NewUiService(
|
||||||
logger wd.Watchdog,
|
logger wd.Watchdog,
|
||||||
skinsRepo model.SkinsRepository,
|
skinsRepo repositories.SkinsRepository,
|
||||||
capesRepo model.CapesRepository,
|
capesRepo repositories.CapesRepository,
|
||||||
) (*uiService, error) {
|
) (*uiService, error) {
|
||||||
return &uiService{
|
return &uiService{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
Loading…
Reference in New Issue
Block a user