27 lines
637 B
Go
27 lines
637 B
Go
package service
|
|
|
|
import (
|
|
"gitea.qpismont.fr/qpismont/trepa/internal/core"
|
|
"gitea.qpismont.fr/qpismont/trepa/internal/variables/domain"
|
|
)
|
|
|
|
type VariableService struct {
|
|
repository domain.VariableRepository
|
|
}
|
|
|
|
func NewService(repository domain.VariableRepository) *VariableService {
|
|
return &VariableService{repository: repository}
|
|
}
|
|
|
|
func (s *VariableService) GetVariable(name string) (*domain.Variable, *core.HTTPError) {
|
|
variable, err := s.repository.FetchOneByName(name)
|
|
if err != nil {
|
|
return nil, core.NewInternalServerError(err)
|
|
}
|
|
|
|
if variable == nil {
|
|
return nil, domain.ErrVariableNotFound
|
|
}
|
|
|
|
return variable, nil
|
|
}
|