update and fix

This commit is contained in:
2025-05-29 02:37:10 +07:00
parent 63d1e85c7f
commit 49999e9e70
9 changed files with 156 additions and 39 deletions
+7 -4
View File
@@ -2,7 +2,6 @@ package story_service
import (
"encoding/json"
"fmt"
"os"
"strings"
)
@@ -56,14 +55,18 @@ func NewStoryService() (*StoryService, error) {
return &StoryService{story: story}, nil
}
func (s *StoryService) GetPlace(code string) (*Place, error) {
func (s *StoryService) GetPlace(code string) *Place {
code = clearCode(code)
for _, place := range s.story.Places {
if clearCode(place.Code) == code {
return place, nil
return place
}
}
return nil, fmt.Errorf("place not found: %s", code)
return &Place{
Code: code,
Name: "Не найдено",
Text: "Такой точки не существует.",
}
}
func clearCode(code string) string {