fix codes

This commit is contained in:
2026-07-28 23:19:48 +07:00
parent cb1f31480c
commit 11798bd4fa
5 changed files with 43 additions and 12 deletions
@@ -171,8 +171,7 @@ func (s *ScenarioService) getStory(ctx context.Context, id int) (*storytelling.S
func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storytelling.Story) error {
mapCodes := map[string]struct{}{}
for _, place := range story.Places {
code := s.cleaner.ClearCode(place.Code)
mapCodes[code] = struct{}{}
mapCodes[place.Code] = struct{}{}
place.Image = strings.TrimPrefix(place.Image, s.domain)
}
if len(mapCodes) != len(story.Places) {
@@ -181,11 +180,9 @@ func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storyt
cleanPlaces := make([]*storytelling.Place, 0, len(story.Places))
for _, place := range story.Places {
code := s.cleaner.ClearCode(place.Code)
if code == "" {
if place.Code == "" {
continue
}
place.Code = code
cleanPlaces = append(cleanPlaces, place)
}
story.Places = cleanPlaces