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