Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

update search show tags

aichy1265e2666390696
diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml
index c89a01ce..03e94e26 100644
--- a/i18n/en_US.yaml
+++ b/i18n/en_US.yaml
@@ -76,6 +76,8 @@ backend:
other: "Tag not found."
recommend_tag_not_found:
other: "Recommend Tag is not exist."
+ not_contain_synonym_tags:
+ other: "Should not contain synonym tags."
theme:
not_found:
other: "Theme not found."
diff --git a/internal/base/reason/reason.go b/internal/base/reason/reason.go
index 200e20cb..25ff1d2f 100644
--- a/internal/base/reason/reason.go
+++ b/internal/base/reason/reason.go
@@ -33,6 +33,7 @@ const (
UserSuspended = "error.user.suspended"
ObjectNotFound = "error.object.not_found"
TagNotFound = "error.tag.not_found"
+ TagNotContainSynonym = "error.tag.not_contain_synonym_tags"
RankFailToMeetTheCondition = "error.rank.fail_to_meet_the_condition"
ThemeNotFound = "error.theme.not_found"
LangNotFound = "error.lang.not_found"
diff --git a/internal/repo/search_common/search_repo.go b/internal/repo/search_common/search_repo.go
index b973df8a..9c486613 100644
--- a/internal/repo/search_common/search_repo.go
+++ b/internal/repo/search_common/search_repo.go
@@ -3,10 +3,11 @@ package search_common
import (
"context"
"fmt"
- "github.com/answerdev/answer/pkg/htmltext"
"strings"
"time"
+ "github.com/answerdev/answer/pkg/htmltext"
+
"github.com/answerdev/answer/internal/base/data"
"github.com/answerdev/answer/internal/base/reason"
"github.com/answerdev/answer/internal/entity"
@@ -390,11 +391,12 @@ func (sr *searchRepo) parseResult(ctx context.Context, res []map[string][]byte)
// get tags
err = sr.data.DB.
- Select("`display_name`,`slug_name`,`main_tag_slug_name`").
+ Select("`display_name`,`slug_name`,`main_tag_slug_name`,`recommend`,`reserved`").
Table("tag").
Join("INNER", "tag_rel", "tag.id = tag_rel.tag_id").
Where(builder.Eq{"tag_rel.object_id": r["question_id"]}).
And(builder.Eq{"tag_rel.status": entity.TagRelStatusAvailable}).
+ UseBool("recommend", "reserved").
Find(&tagsEntity)
if err != nil {
diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go
index dfdce839..fb28d744 100644
--- a/internal/service/tag_common/tag_common.go
+++ b/internal/service/tag_common/tag_common.go
@@ -244,6 +244,10 @@ func (ts *TagCommonService) UpdateTag(ctx context.Context, tags []string, userID
tagInDbMapping := make(map[string]*entity.Tag)
for _, tag := range tagListInDb {
+ if tag.MainTagID != 0 {
+ err = errors.BadRequest(reason.TagNotContainSynonym).WithMsg(fmt.Sprintf("tag name:%s", tag.SlugName))
+ return err
+ }
tagInDbMapping[tag.SlugName] = tag
thisTagIDList = append(thisTagIDList, tag.ID)
}