generated from VLADIMIR/template
up
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
type IScenariosRepository interface {
|
||||
AddScenario(ctx context.Context, name string, authorID int) (int, error)
|
||||
GetScenariosByAuthorID(ctx context.Context, authorID int) ([]*repos.Scenario, error)
|
||||
GetAllScenarios(ctx context.Context) ([]*repos.Scenario, error)
|
||||
GetScenariosByStatus(ctx context.Context, status string) ([]*repos.Scenario, error)
|
||||
GetScenarioByID(ctx context.Context, id int) (*repos.Scenario, error)
|
||||
UpdateScenarioByID(ctx context.Context, id int, name string, description string, image string) error
|
||||
@@ -77,6 +78,15 @@ func (s *ScenarioService) GetScenariosByAuthorID(
|
||||
return mapScenariosLight(scenarios, s.domain), nil
|
||||
}
|
||||
|
||||
// GetAllScenarios returns all non-deleted scenarios.
|
||||
func (s *ScenarioService) GetAllScenarios(ctx context.Context) ([]*Scenario, error) {
|
||||
scenarios, err := s.scenariosRepo.GetAllScenarios(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mapScenariosLight(scenarios, s.domain), nil
|
||||
}
|
||||
|
||||
// GetScenariosCatalog returns scenarios available in the catalog.
|
||||
func (s *ScenarioService) GetScenariosCatalog(
|
||||
ctx context.Context,
|
||||
|
||||
@@ -193,6 +193,16 @@ func (r *fakeScenariosRepo) GetScenariosByAuthorID(_ context.Context, authorID i
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (r *fakeScenariosRepo) GetAllScenarios(_ context.Context) ([]*repos.Scenario, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
res := make([]*repos.Scenario, 0, len(r.byID))
|
||||
for _, s := range r.byID {
|
||||
res = append(res, s)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (r *fakeScenariosRepo) GetScenariosByStatus(_ context.Context, status string) ([]*repos.Scenario, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user