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 tag show
aichy1260863eec2a038
diff --git a/docs/docs.go b/docs/docs.goindex aee0a267..9c978507 100644--- a/docs/docs.go+++ b/docs/docs.go@@ -4776,6 +4776,12 @@ const docTemplate = `{"description": "if main tag slug name is not empty, this tag is synonymous with the main tag","type": "string"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5054,6 +5060,12 @@ const docTemplate = `{"description": "question amount","type": "integer"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug_name","type": "string"@@ -5114,6 +5126,12 @@ const docTemplate = `{"description": "question amount","type": "integer"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5139,6 +5157,12 @@ const docTemplate = `{"description": "if main tag slug name is not empty, this tag is synonymous with the main tag","type": "string"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5953,6 +5977,9 @@ const docTemplate = `{"recommend": {"type": "boolean"},+ "reserved": {+ "type": "boolean"+ },"slug_name": {"type": "string"}diff --git a/docs/swagger.json b/docs/swagger.jsonindex 4c3c2c3a..78aa5450 100644--- a/docs/swagger.json+++ b/docs/swagger.json@@ -4764,6 +4764,12 @@"description": "if main tag slug name is not empty, this tag is synonymous with the main tag","type": "string"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5042,6 +5048,12 @@"description": "question amount","type": "integer"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug_name","type": "string"@@ -5102,6 +5114,12 @@"description": "question amount","type": "integer"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5127,6 +5145,12 @@"description": "if main tag slug name is not empty, this tag is synonymous with the main tag","type": "string"},+ "recommend": {+ "type": "boolean"+ },+ "reserved": {+ "type": "boolean"+ },"slug_name": {"description": "slug name","type": "string"@@ -5941,6 +5965,9 @@"recommend": {"type": "boolean"},+ "reserved": {+ "type": "boolean"+ },"slug_name": {"type": "string"}diff --git a/docs/swagger.yaml b/docs/swagger.yamlindex a4fca4e2..932b0506 100644--- a/docs/swagger.yaml+++ b/docs/swagger.yaml@@ -368,6 +368,10 @@ definitions:description: if main tag slug name is not empty, this tag is synonymous withthe main tagtype: string+ recommend:+ type: boolean+ reserved:+ type: booleanslug_name:description: slug nametype: string@@ -570,6 +574,10 @@ definitions:question_count:description: question amounttype: integer+ recommend:+ type: boolean+ reserved:+ type: booleanslug_name:description: slug_nametype: string@@ -615,6 +623,10 @@ definitions:question_count:description: question amounttype: integer+ recommend:+ type: boolean+ reserved:+ type: booleanslug_name:description: slug nametype: string@@ -634,6 +646,10 @@ definitions:description: if main tag slug name is not empty, this tag is synonymous withthe main tagtype: string+ recommend:+ type: boolean+ reserved:+ type: booleanslug_name:description: slug nametype: string@@ -1223,6 +1239,8 @@ definitions:type: stringrecommend:type: boolean+ reserved:+ type: booleanslug_name:type: stringtype: objectdiff --git a/internal/repo/tag/tag_repo.go b/internal/repo/tag/tag_repo.goindex 95f4dde1..76ab6cbf 100644--- a/internal/repo/tag/tag_repo.go+++ b/internal/repo/tag/tag_repo.go@@ -128,7 +128,7 @@ func (tr *tagRepo) GetReservedTagList(ctx context.Context) (tagList []*entity.Ta// GetTagListByNames get tag list all like namefunc (tr *tagRepo) GetTagListByNames(ctx context.Context, names []string) (tagList []*entity.Tag, err error) {tagList = make([]*entity.Tag, 0)- session := tr.data.DB.In("slug_name", names)+ session := tr.data.DB.In("slug_name", names).UseBool("recommend", "reserved")// session.Where(builder.Eq{"status": entity.TagStatusAvailable})err = session.OrderBy("recommend desc,reserved desc,id desc").Find(&tagList)if err != nil {diff --git a/internal/schema/tag_schema.go b/internal/schema/tag_schema.goindex f22b89b3..0ab27033 100644--- a/internal/schema/tag_schema.go+++ b/internal/schema/tag_schema.go@@ -61,6 +61,8 @@ type GetTagResp struct {MemberActions []*PermissionMemberAction `json:"member_actions"`// if main tag slug name is not empty, this tag is synonymous with the main tagMainTagSlugName string `json:"main_tag_slug_name"`+ Recommend bool `json:"recommend"`+ Reserved bool `json:"reserved"`}func (tr *GetTagResp) GetExcerpt() {@@ -96,6 +98,8 @@ type GetTagPageResp struct {CreatedAt int64 `json:"created_at"`// updated timeUpdatedAt int64 `json:"updated_at"`+ Recommend bool `json:"recommend"`+ Reserved bool `json:"reserved"`}func (tr *GetTagPageResp) GetExcerpt() {@@ -190,6 +194,8 @@ type GetTagSynonymsResp struct {DisplayName string `json:"display_name"`// if main tag slug name is not empty, this tag is synonymous with the main tagMainTagSlugName string `json:"main_tag_slug_name"`+ Recommend bool `json:"recommend"`+ Reserved bool `json:"reserved"`}// UpdateTagSynonymReq update tag request@@ -218,6 +224,8 @@ type GetFollowingTagsResp struct {DisplayName string `json:"display_name"`// if main tag slug name is not empty, this tag is synonymous with the main tagMainTagSlugName string `json:"main_tag_slug_name"`+ Recommend bool `json:"recommend"`+ Reserved bool `json:"reserved"`}type SearchTagLikeResp struct {diff --git a/internal/service/revision_service.go b/internal/service/revision_service.goindex bb5443a3..fe9da647 100644--- a/internal/service/revision_service.go+++ b/internal/service/revision_service.go@@ -113,6 +113,8 @@ func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisiParsedText: tag.ParsedText,FollowCount: tag.FollowCount,QuestionCount: tag.QuestionCount,+ Recommend: tag.Recommend,+ Reserved: tag.Reserved,}tagInfo.GetExcerpt()item.ContentParsed = tagInfodiff --git a/internal/service/search/tag.go b/internal/service/search/tag.goindex 73bd3a71..6fa59936 100644--- a/internal/service/search/tag.go+++ b/internal/service/search/tag.go@@ -82,6 +82,8 @@ func (ts *TagSearch) Search(ctx context.Context) (resp []schema.SearchResp, totaParsedText: tag.ParsedText,QuestionCount: tag.QuestionCount,IsFollower: followed,+ Recommend: tag.Recommend,+ Reserved: tag.Reserved,}ts.Extra.GetExcerpt()diff --git a/internal/service/tag/tag_service.go b/internal/service/tag/tag_service.goindex aa012be3..641717c2 100644--- a/internal/service/tag/tag_service.go+++ b/internal/service/tag/tag_service.go@@ -157,6 +157,8 @@ func (ts *TagService) GetTagInfo(ctx context.Context, req *schema.GetTagInfoReq)resp.ParsedText = tagInfo.ParsedTextresp.FollowCount = tagInfo.FollowCountresp.QuestionCount = tagInfo.QuestionCount+ resp.Recommend = tagInfo.Recommend+ resp.Reserved = tagInfo.Reservedresp.IsFollower = ts.checkTagIsFollow(ctx, req.UserID, tagInfo.ID)resp.MemberActions = permission.GetTagPermission(req.UserID, req.UserID)resp.GetExcerpt()@@ -183,6 +185,8 @@ func (ts *TagService) GetFollowingTags(ctx context.Context, userID string) (TagID: t.ID,SlugName: t.SlugName,DisplayName: t.DisplayName,+ Recommend: t.Recommend,+ Reserved: t.Reserved,}if t.MainTagID > 0 {mainTag, exist, err := ts.tagRepo.GetTagByID(ctx, converter.IntToString(t.MainTagID))@@ -239,6 +243,8 @@ func (ts *TagService) GetTagSynonyms(ctx context.Context, req *schema.GetTagSynoSlugName: t.SlugName,DisplayName: t.DisplayName,MainTagSlugName: mainTagSlugName,+ Recommend: t.Recommend,+ Reserved: t.Reserved,})}return@@ -364,6 +370,8 @@ func (ts *TagService) GetTagWithPage(ctx context.Context, req *schema.GetTagWithIsFollower: ts.checkTagIsFollow(ctx, req.UserID, tag.ID),CreatedAt: tag.CreatedAt.Unix(),UpdatedAt: tag.UpdatedAt.Unix(),+ Recommend: tag.Recommend,+ Reserved: tag.Reserved,})}return pager.NewPageModel(total, resp), nildiff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.goindex fb28d744..0a55b857 100644--- a/internal/service/tag_common/tag_common.go+++ b/internal/service/tag_common/tag_common.go@@ -4,6 +4,7 @@ import ("context""encoding/json""fmt"+ "sort""strings""github.com/answerdev/answer/internal/base/reason"@@ -221,6 +222,14 @@ func (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []sobjectIDTagMap[item.ObjectID] = append(objectIDTagMap[item.ObjectID], t)}}+ for _, taglist := range objectIDTagMap {+ sort.SliceStable(taglist, func(i, j int) bool {+ return taglist[i].Reserved+ })+ sort.SliceStable(taglist, func(i, j int) bool {+ return taglist[i].Recommend+ })+ }return objectIDTagMap, nil}