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
@@ -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
@@ -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
}