mirror of https://gitee.com/answerdev/answer.git
Merge branch 'ai/0.4.0/tag' into 'test'
update search show tags See merge request opensource/answer!241
This commit is contained in:
commit
8ba55f5955
|
@ -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."
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
@ -419,11 +420,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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue