Skip to content

Commit 6f91bc8

Browse files
committed
update tag
1 parent 1cd1946 commit 6f91bc8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/service/question_service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func (qs *QuestionService) AddQuestion(ctx context.Context, req *schema.Question
235235

236236
tagNameList := make([]string, 0)
237237
for _, tag := range req.Tags {
238+
tag.SlugName = strings.ReplaceAll(tag.SlugName, " ", "-")
238239
tagNameList = append(tagNameList, tag.SlugName)
239240
}
240241
Tags, tagerr := qs.tagCommon.GetTagListByNames(ctx, tagNameList)
@@ -495,6 +496,7 @@ func (qs *QuestionService) UpdateQuestion(ctx context.Context, req *schema.Quest
495496
tagNameList := make([]string, 0)
496497
oldtagNameList := make([]string, 0)
497498
for _, tag := range req.Tags {
499+
tag.SlugName = strings.ReplaceAll(tag.SlugName, " ", "-")
498500
tagNameList = append(tagNameList, tag.SlugName)
499501
}
500502
for _, tag := range oldTags {

internal/service/tag_common/tag_common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ func (ts *TagCommonService) ExistRecommend(ctx context.Context, tags []*schema.T
200200
}
201201
tagNames := make([]string, 0)
202202
for _, item := range tags {
203+
item.SlugName = strings.ReplaceAll(item.SlugName, " ", "-")
203204
tagNames = append(tagNames, item.SlugName)
204205
}
205206
list, err := ts.GetTagListByNames(ctx, tagNames)
@@ -233,7 +234,7 @@ func (ts *TagCommonService) AddTag(ctx context.Context, req *schema.AddTagReq) (
233234
return nil, errors.BadRequest(reason.TagAlreadyExist)
234235
}
235236
tagInfo := &entity.Tag{
236-
SlugName: req.SlugName,
237+
SlugName: strings.ReplaceAll(req.SlugName, " ", "-"),
237238
DisplayName: req.DisplayName,
238239
OriginalText: req.OriginalText,
239240
ParsedText: req.ParsedText,
@@ -557,7 +558,7 @@ func (ts *TagCommonService) ObjectChangeTag(ctx context.Context, objectTagData *
557558
continue
558559
}
559560
item := &entity.Tag{}
560-
item.SlugName = tag.SlugName
561+
item.SlugName = strings.ReplaceAll(tag.SlugName, " ", "-")
561562
item.DisplayName = tag.DisplayName
562563
item.OriginalText = tag.OriginalText
563564
item.ParsedText = tag.ParsedText

0 commit comments

Comments
 (0)