This commit is contained in:
2026-07-24 01:14:28 +07:00
parent c79cff2709
commit 37372cdd86
3 changed files with 4 additions and 6 deletions
Binary file not shown.
@@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"evening_detective_server/internal/modules/storytelling" "evening_detective_server/internal/modules/storytelling"
"evening_detective_server/internal/repos" "evening_detective_server/internal/repos"
"strings"
) )
func mapScenarios( func mapScenarios(
@@ -58,10 +57,7 @@ func mapStory(o string, domain string) (*storytelling.Story, error) {
return res, nil return res, nil
} }
func convertStory(o *storytelling.Story, domain string) (string, error) { func convertStory(o *storytelling.Story) (string, error) {
for _, place := range o.Places {
place.Image = strings.TrimLeft(place.Image, domain)
}
b, err := json.Marshal(o) b, err := json.Marshal(o)
if err != nil { if err != nil {
return "", err return "", err
@@ -5,6 +5,7 @@ import (
"errors" "errors"
"evening_detective_server/internal/modules/storytelling" "evening_detective_server/internal/modules/storytelling"
"evening_detective_server/internal/repos/scenarios_repo" "evening_detective_server/internal/repos/scenarios_repo"
"strings"
) )
type ScenarioService struct { type ScenarioService struct {
@@ -138,12 +139,13 @@ func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storyt
mapCodes := map[string]struct{}{} mapCodes := map[string]struct{}{}
for _, place := range story.Places { for _, place := range story.Places {
mapCodes[place.Code] = struct{}{} mapCodes[place.Code] = struct{}{}
place.Image = strings.TrimPrefix(place.Image, s.domain)
} }
if len(mapCodes) != len(story.Places) { if len(mapCodes) != len(story.Places) {
return errors.New("Такой код точки уже существует") return errors.New("Такой код точки уже существует")
} }
storyString, err := convertStory(story, s.domain) storyString, err := convertStory(story)
if err != nil { if err != nil {
return err return err
} }