This commit is contained in:
2021-08-24 00:11:00 +02:00
parent 57bde4ac3c
commit 0757262143
22 changed files with 716 additions and 632 deletions

View File

@@ -1,30 +0,0 @@
package service
import (
"hamster-tycoon/storage/dao"
"hamster-tycoon/storage/model"
)
type GameService struct {
serviceContext
}
func NewGameService(database dao.Database) *GameService {
return &GameService{serviceContext{db: database}}
}
func (gs *GameService) GetAGameByID(id string) (*model.Game, error) {
game, err := gs.db.GetGameByID(id)
if err != nil {
if castedError, ok := err.(*dao.Error); ok {
switch castedError.Type {
case dao.ErrTypeNotFound:
return nil, &model.ErrNotFound
default:
return nil, &model.ErrInternalServer
}
}
return nil, &model.ErrInternalServer
}
return game, nil
}