24 lines
514 B
Go
24 lines
514 B
Go
package site
|
|
|
|
import "context"
|
|
|
|
type Service struct {
|
|
repo Repository
|
|
}
|
|
|
|
func NewService(repo Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) Get(ctx context.Context) (*Settings, error) {
|
|
return s.repo.Get(ctx)
|
|
}
|
|
|
|
func (s *Service) Update(ctx context.Context, name, description, slug string) (*Settings, error) {
|
|
settings := &Settings{Name: name, Description: description, Slug: slug}
|
|
if err := s.repo.Update(ctx, settings); err != nil {
|
|
return nil, err
|
|
}
|
|
return s.repo.Get(ctx)
|
|
}
|