add images

This commit is contained in:
2026-07-24 00:49:37 +07:00
parent ea236027db
commit 871331f14d
3 changed files with 8 additions and 3 deletions
Binary file not shown.
@@ -25,7 +25,7 @@ func mapScenario(
o *repos.Scenario, o *repos.Scenario,
domain string, domain string,
) (*Scenario, error) { ) (*Scenario, error) {
story, err := mapStory(o.Scenario) story, err := mapStory(o.Scenario, domain)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -44,11 +44,16 @@ func mapScenario(
}, nil }, nil
} }
func mapStory(o string) (*storytelling.Story, error) { func mapStory(o string, domain string) (*storytelling.Story, error) {
res := &storytelling.Story{} res := &storytelling.Story{}
if err := json.Unmarshal([]byte(o), res); err != nil { if err := json.Unmarshal([]byte(o), res); err != nil {
return nil, err return nil, err
} }
for _, place := range res.Places {
if place.Image != "" {
place.Image = domain + place.Image
}
}
return res, nil return res, nil
} }
@@ -131,7 +131,7 @@ func (s *ScenarioService) getStory(ctx context.Context, id int) (*storytelling.S
if err != nil { if err != nil {
return nil, err return nil, err
} }
return mapStory(storyString) return mapStory(storyString, s.domain)
} }
func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storytelling.Story) error { func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storytelling.Story) error {