diff --git a/bin/evening_detective_server b/bin/evening_detective_server index 7cc621f..8294f1a 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/internal/services/scenarios_service/scenario_mapper.go b/internal/services/scenarios_service/scenario_mapper.go index ea667d0..d58c519 100644 --- a/internal/services/scenarios_service/scenario_mapper.go +++ b/internal/services/scenarios_service/scenario_mapper.go @@ -4,7 +4,6 @@ import ( "encoding/json" "evening_detective_server/internal/modules/storytelling" "evening_detective_server/internal/repos" - "strings" ) func mapScenarios( @@ -58,10 +57,7 @@ func mapStory(o string, domain string) (*storytelling.Story, error) { return res, nil } -func convertStory(o *storytelling.Story, domain string) (string, error) { - for _, place := range o.Places { - place.Image = strings.TrimLeft(place.Image, domain) - } +func convertStory(o *storytelling.Story) (string, error) { b, err := json.Marshal(o) if err != nil { return "", err diff --git a/internal/services/scenarios_service/service.go b/internal/services/scenarios_service/service.go index 4e5ac2b..65515d9 100644 --- a/internal/services/scenarios_service/service.go +++ b/internal/services/scenarios_service/service.go @@ -5,6 +5,7 @@ import ( "errors" "evening_detective_server/internal/modules/storytelling" "evening_detective_server/internal/repos/scenarios_repo" + "strings" ) type ScenarioService struct { @@ -138,12 +139,13 @@ func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storyt mapCodes := map[string]struct{}{} for _, place := range story.Places { mapCodes[place.Code] = struct{}{} + place.Image = strings.TrimPrefix(place.Image, s.domain) } if len(mapCodes) != len(story.Places) { return errors.New("Такой код точки уже существует") } - storyString, err := convertStory(story, s.domain) + storyString, err := convertStory(story) if err != nil { return err }