replace space from title and field name always

This commit is contained in:
Pavel 2024-06-23 18:17:28 +03:00
parent 35e57bdb80
commit 99aa82959d
2 changed files with 7 additions and 5 deletions

@ -57,13 +57,14 @@ func ToCreatedUpdateQuestionRules(questionsTypeMap map[model.EntityType][]model.
for entity, questions := range questionsTypeMap { for entity, questions := range questionsTypeMap {
for _, question := range questions { for _, question := range questions {
// если заголоввок пустой у вопроса делаем ему заголовок чтоб в амо легли филды нормально // если заголоввок пустой у вопроса делаем ему заголовок чтоб в амо легли филды нормально
title := strings.ReplaceAll(question.Title, " ", "") title := strings.ToLower(strings.ReplaceAll(question.Title, " ", ""))
if 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 matched := false
for _, field := range currentFields { for _, field := range currentFields {
fieldName := strings.ReplaceAll(field.Name, " ", "") fieldName := strings.ToLower(strings.ReplaceAll(field.Name, " ", ""))
if title == fieldName && entity == field.Entity { if title == fieldName && entity == field.Entity {
toUpdate[int(question.Id)] = ToUpdate{ toUpdate[int(question.Id)] = ToUpdate{
FieldID: int(field.Amoid), FieldID: int(field.Amoid),

@ -679,12 +679,13 @@ func (m *Methods) CheckFieldRule(ctx context.Context, token string, msg models.K
} }
if questionID == int(question.Id) { if questionID == int(question.Id) {
// тут также делаем чтобы сверить филд с вопросом // тут также делаем чтобы сверить филд с вопросом
title := strings.ReplaceAll(question.Title, " ", "") title := strings.ToLower(strings.ReplaceAll(question.Title, " ", ""))
if title == "" { if title == "" {
question.Title = fmt.Sprintf("Вопрос №%d", question.Page) question.Title = fmt.Sprintf("Вопрос №%d", question.Page)
} }
title = strings.ToLower(strings.ReplaceAll(question.Title, " ", ""))
for _, field := range newFields { for _, field := range newFields {
fieldName := strings.ReplaceAll(field.Name, " ", "") fieldName := strings.ToLower(strings.ReplaceAll(field.Name, " ", ""))
if title == fieldName && field.Entity == currentEntity { if title == fieldName && field.Entity == currentEntity {
ruleMap := make(map[int]int) ruleMap := make(map[int]int)
ruleMap[questionID] = int(field.Amoid) ruleMap[questionID] = int(field.Amoid)