This commit is contained in:
2025-05-19 03:18:22 +07:00
parent 107504317e
commit e409a69a54
23 changed files with 336 additions and 199 deletions
+24 -3
View File
@@ -2,12 +2,29 @@ package story_service
import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"
)
var (
replaceMap = map[string]string{
"a": "а",
"e": "е",
"o": "о",
"c": "с",
"p": "р",
"x": "х",
"y": "у",
"k": "к",
"m": "м",
"t": "т",
"h": "н",
"b": "в",
"u": "и",
}
)
type Story struct {
Places []*Place `json:"places"`
}
@@ -46,10 +63,14 @@ func (s *StoryService) GetPlace(code string) (*Place, error) {
return place, nil
}
}
return nil, errors.New(fmt.Sprintf("place not found: %s", code))
return nil, fmt.Errorf("place not found: %s", code)
}
func clearCode(code string) string {
code = strings.ToLower(code)
return strings.ReplaceAll(code, "-", "")
code = strings.ReplaceAll(code, "-", "")
for latin, cyrillic := range replaceMap {
code = strings.ReplaceAll(code, latin, cyrillic)
}
return code
}