34 lines
715 B
Go
34 lines
715 B
Go
package systemconfig
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrDependencyUnavailable = errors.New("dependency unavailable")
|
|
ErrInvalidConfig = errors.New("invalid config")
|
|
)
|
|
|
|
type Service struct {
|
|
repo *Repository
|
|
}
|
|
|
|
func NewService(repo *Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) List() ([]ConfigDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.List()
|
|
}
|
|
|
|
func (s *Service) Update(actorID uint64, key string, req UpdateRequest, meta AuditMeta) (*ConfigDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if key == "" || req.Value == "" {
|
|
return nil, ErrInvalidConfig
|
|
}
|
|
return s.repo.Update(actorID, key, req, meta)
|
|
}
|