replace space from title and field name always

This commit is contained in:
Pavel 2024-06-23 17:52:17 +03:00
parent 09a4271a9a
commit 35e57bdb80
2 changed files with 5 additions and 3 deletions

@ -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,

@ -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})