From 99aa82959dd008c1c9916b8c146f613f0054380e Mon Sep 17 00:00:00 2001 From: Pavel Date: Sun, 23 Jun 2024 18:17:28 +0300 Subject: [PATCH] replace space from title and field name always --- internal/tools/for_rules.go | 7 ++++--- internal/workers_methods/methods.go | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/tools/for_rules.go b/internal/tools/for_rules.go index cacdfd3..90004b7 100644 --- a/internal/tools/for_rules.go +++ b/internal/tools/for_rules.go @@ -57,13 +57,14 @@ func ToCreatedUpdateQuestionRules(questionsTypeMap map[model.EntityType][]model. for entity, questions := range questionsTypeMap { for _, question := range questions { // если заголоввок пустой у вопроса делаем ему заголовок чтоб в амо легли филды нормально - title := strings.ReplaceAll(question.Title, " ", "") + title := strings.ToLower(strings.ReplaceAll(question.Title, " ", "")) if title == "" { - title = fmt.Sprintf("Вопрос №%d", question.Page) + question.Title = fmt.Sprintf("Вопрос №%d", question.Page) } + title = strings.ToLower(strings.ReplaceAll(question.Title, " ", "")) matched := false for _, field := range currentFields { - fieldName := strings.ReplaceAll(field.Name, " ", "") + fieldName := strings.ToLower(strings.ReplaceAll(field.Name, " ", "")) if title == fieldName && entity == field.Entity { toUpdate[int(question.Id)] = ToUpdate{ FieldID: int(field.Amoid), diff --git a/internal/workers_methods/methods.go b/internal/workers_methods/methods.go index 7a82c1a..6309f04 100644 --- a/internal/workers_methods/methods.go +++ b/internal/workers_methods/methods.go @@ -679,12 +679,13 @@ func (m *Methods) CheckFieldRule(ctx context.Context, token string, msg models.K } if questionID == int(question.Id) { // тут также делаем чтобы сверить филд с вопросом - title := strings.ReplaceAll(question.Title, " ", "") + title := strings.ToLower(strings.ReplaceAll(question.Title, " ", "")) if title == "" { question.Title = fmt.Sprintf("Вопрос №%d", question.Page) } + title = strings.ToLower(strings.ReplaceAll(question.Title, " ", "")) for _, field := range newFields { - fieldName := strings.ReplaceAll(field.Name, " ", "") + fieldName := strings.ToLower(strings.ReplaceAll(field.Name, " ", "")) if title == fieldName && field.Entity == currentEntity { ruleMap := make(map[int]int) ruleMap[questionID] = int(field.Amoid)