add intro

This commit is contained in:
2026-08-28 22:02:58 +07:00
parent 5fcbf6f2c5
commit 1a05799b2d
17 changed files with 1103 additions and 364 deletions
@@ -278,6 +278,25 @@ func (s *ScenarioService) DeleteScenarioPlace(
return s.updateStory(ctx, id, story)
}
// UpdateScenarioIntro сохраняет введение сценария (текст и аудио).
func (s *ScenarioService) UpdateScenarioIntro(
ctx context.Context,
id int,
introduction *storytelling.Introduction,
actorId int,
isAdmin bool,
) error {
if _, err := s.getScenarioForChange(ctx, id, actorId, isAdmin); err != nil {
return err
}
story, err := s.getStory(ctx, id)
if err != nil {
return err
}
story.Introduction = introduction
return s.updateStory(ctx, id, story)
}
func (s *ScenarioService) getStory(ctx context.Context, id int) (*storytelling.Story, error) {
storyString, err := s.scenariosRepo.GetStoryByScenarioID(ctx, id)
if err != nil {
@@ -385,6 +404,12 @@ func (s *ScenarioService) UploadArchive(
}
}
}
if scenario.Story.Introduction != nil {
scenario.Story.Introduction.Audio, err = rewrite(scenario.Story.Introduction.Audio)
if err != nil {
return 0, err
}
}
storyJSON, err := normalizeStory(scenario.Story)
if err != nil {
@@ -423,6 +448,9 @@ func (s *ScenarioService) updateStory(ctx context.Context, id int, story *storyt
for _, place := range story.Places {
place.Image = strings.TrimPrefix(place.Image, s.domain)
}
if story.Introduction != nil {
story.Introduction.Audio = strings.TrimPrefix(story.Introduction.Audio, s.domain)
}
storyString, err := normalizeStory(story)
if err != nil {
return err