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.
refactor: tag repo remove site info service
LinkinStar432f8c330957
diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.goindex aa07fc7d..d8ea06b3 100644--- a/cmd/answer/wire_gen.go+++ b/cmd/answer/wire_gen.go@@ -116,7 +116,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,userCommon := usercommon.NewUserCommon(userRepo)answerRepo := answer.NewAnswerRepo(dataData, uniqueIDRepo, userRankRepo, activityRepo)questionRepo := question.NewQuestionRepo(dataData, uniqueIDRepo)- tagCommonRepo := tag_common.NewTagCommonRepo(dataData, uniqueIDRepo, siteInfoCommonService)+ tagCommonRepo := tag_common.NewTagCommonRepo(dataData, uniqueIDRepo)objService := object_info.NewObjService(answerRepo, questionRepo, commentCommonRepo, tagCommonRepo)voteRepo := activity_common.NewVoteRepo(dataData, activityRepo)commentService := comment2.NewCommentService(commentRepo, commentCommonRepo, userCommon, objService, voteRepo)@@ -128,19 +128,19 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,serviceVoteRepo := activity.NewVoteRepo(dataData, uniqueIDRepo, configRepo, activityRepo, userRankRepo, voteRepo)voteService := service.NewVoteService(serviceVoteRepo, uniqueIDRepo, configRepo, questionRepo, answerRepo, commentCommonRepo, objService)voteController := controller.NewVoteController(voteService)- tagRepo := tag.NewTagRepo(dataData, uniqueIDRepo, siteInfoCommonService)+ tagRepo := tag.NewTagRepo(dataData, uniqueIDRepo)+ tagRelRepo := tag.NewTagRelRepo(dataData)revisionRepo := revision.NewRevisionRepo(dataData, uniqueIDRepo)revisionService := revision_common.NewRevisionService(revisionRepo, userRepo)+ tagCommonService := tag_common2.NewTagCommonService(tagCommonRepo, tagRelRepo, revisionService, siteInfoCommonService)followRepo := activity_common.NewFollowRepo(dataData, uniqueIDRepo, activityRepo)- tagService := tag2.NewTagService(tagRepo, tagCommonRepo, revisionService, followRepo, siteInfoCommonService)+ tagService := tag2.NewTagService(tagRepo, tagCommonService, revisionService, followRepo, siteInfoCommonService)tagController := controller.NewTagController(tagService, rankService)followFollowRepo := activity.NewFollowRepo(dataData, uniqueIDRepo, activityRepo)followService := follow.NewFollowService(followFollowRepo, followRepo, tagCommonRepo)followController := controller.NewFollowController(followService)collectionRepo := collection.NewCollectionRepo(dataData, uniqueIDRepo)collectionGroupRepo := collection.NewCollectionGroupRepo(dataData)- tagRelRepo := tag.NewTagRelRepo(dataData)- tagCommonService := tag_common2.NewTagCommonService(tagCommonRepo, tagRelRepo, revisionService, siteInfoCommonService)collectionCommon := collectioncommon.NewCollectionCommon(collectionRepo)answerCommon := answercommon.NewAnswerCommon(answerRepo)metaRepo := meta.NewMetaRepo(dataData)@@ -157,7 +157,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database,dashboardService := dashboard.NewDashboardService(questionRepo, answerRepo, commentCommonRepo, voteRepo, userRepo, reportRepo, configRepo, siteInfoCommonService, serviceConf, dataData)answerController := controller.NewAnswerController(answerService, rankService, dashboardService)searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon)- searchService := service.NewSearchService(searchRepo, tagCommonRepo, userCommon, followRepo)+ searchService := service.NewSearchService(searchRepo, tagCommonService, userCommon, followRepo)searchController := controller.NewSearchController(searchService)serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService)revisionController := controller.NewRevisionController(serviceRevisionService)diff --git a/internal/repo/tag/tag_repo.go b/internal/repo/tag/tag_repo.goindex 36591d45..4a9222e3 100644--- a/internal/repo/tag/tag_repo.go+++ b/internal/repo/tag/tag_repo.go@@ -6,7 +6,6 @@ import ("github.com/answerdev/answer/internal/base/data""github.com/answerdev/answer/internal/base/reason""github.com/answerdev/answer/internal/entity"- "github.com/answerdev/answer/internal/service/siteinfo_common""github.com/answerdev/answer/internal/service/tag""github.com/answerdev/answer/internal/service/unique""github.com/segmentfault/pacman/errors"@@ -15,21 +14,18 @@ import (// tagRepo tag repositorytype tagRepo struct {- data *data.Data- uniqueIDRepo unique.UniqueIDRepo- siteInfoService *siteinfo_common.SiteInfoCommonService+ data *data.Data+ uniqueIDRepo unique.UniqueIDRepo}// NewTagRepo new repositoryfunc NewTagRepo(data *data.Data,uniqueIDRepo unique.UniqueIDRepo,- siteInfoService *siteinfo_common.SiteInfoCommonService,) tag.TagRepo {return &tagRepo{- data: data,- uniqueIDRepo: uniqueIDRepo,- siteInfoService: siteInfoService,+ data: data,+ uniqueIDRepo: uniqueIDRepo,}}diff --git a/internal/repo/tag_common/tag_common_repo.go b/internal/repo/tag_common/tag_common_repo.goindex 4bdaaf89..50f8517f 100644--- a/internal/repo/tag_common/tag_common_repo.go+++ b/internal/repo/tag_common/tag_common_repo.go@@ -7,43 +7,29 @@ import ("github.com/answerdev/answer/internal/base/pager""github.com/answerdev/answer/internal/base/reason""github.com/answerdev/answer/internal/entity"- "github.com/answerdev/answer/internal/service/siteinfo_common"tagcommon "github.com/answerdev/answer/internal/service/tag_common""github.com/answerdev/answer/internal/service/unique""github.com/segmentfault/pacman/errors"- "github.com/segmentfault/pacman/log""xorm.io/builder")// tagCommonRepo tag repositorytype tagCommonRepo struct {- data *data.Data- uniqueIDRepo unique.UniqueIDRepo- siteInfoService *siteinfo_common.SiteInfoCommonService+ data *data.Data+ uniqueIDRepo unique.UniqueIDRepo}// NewTagCommonRepo new repositoryfunc NewTagCommonRepo(data *data.Data,uniqueIDRepo unique.UniqueIDRepo,- siteInfoService *siteinfo_common.SiteInfoCommonService,) tagcommon.TagCommonRepo {return &tagCommonRepo{- data: data,- uniqueIDRepo: uniqueIDRepo,- siteInfoService: siteInfoService,+ data: data,+ uniqueIDRepo: uniqueIDRepo,}}-func (tr *tagCommonRepo) tagRecommendStatus(ctx context.Context) bool {- tagconfig, err := tr.siteInfoService.GetSiteWrite(ctx)- if err != nil {- log.Error("siteInfoService.GetSiteWrite error", err)- return false- }- return tagconfig.RequiredTag-}-// GetTagListByIDs get tag list allfunc (tr *tagCommonRepo) GetTagListByIDs(ctx context.Context, ids []string) (tagList []*entity.Tag, err error) {tagList = make([]*entity.Tag, 0)@@ -53,11 +39,6 @@ func (tr *tagCommonRepo) GetTagListByIDs(ctx context.Context, ids []string) (tagif err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}@@ -70,10 +51,6 @@ func (tr *tagCommonRepo) GetTagBySlugName(ctx context.Context, slugName string)if err != nil {return nil, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}-- if !tr.tagRecommendStatus(ctx) {- tagInfo.Recommend = false- }return}@@ -99,11 +76,6 @@ func (tr *tagCommonRepo) GetTagListByName(ctx context.Context, name string, limiif err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}@@ -119,11 +91,6 @@ func (tr *tagCommonRepo) GetRecommendTagList(ctx context.Context) (tagList []*enif err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}@@ -139,11 +106,6 @@ func (tr *tagCommonRepo) GetReservedTagList(ctx context.Context) (tagList []*entif err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}@@ -156,11 +118,6 @@ func (tr *tagCommonRepo) GetTagListByNames(ctx context.Context, names []string)if err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}@@ -175,9 +132,6 @@ func (tr *tagCommonRepo) GetTagByID(ctx context.Context, tagID string) (if err != nil {return nil, false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- tag.Recommend = false- }return}@@ -208,11 +162,6 @@ func (tr *tagCommonRepo) GetTagPage(ctx context.Context, page, pageSize int, tagif err != nil {err = errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()}- if !tr.tagRecommendStatus(ctx) {- for _, tag := range tagList {- tag.Recommend = false- }- }return}diff --git a/internal/service/question_service.go b/internal/service/question_service.goindex 437d7936..6f36fbe7 100644--- a/internal/service/question_service.go+++ b/internal/service/question_service.go@@ -539,14 +539,13 @@ func (qs *QuestionService) SimilarQuestion(ctx context.Context, questionID strin// SearchListfunc (qs *QuestionService) SearchList(ctx context.Context, req *schema.QuestionSearch, loginUserID string) ([]*schema.QuestionInfo, int64, error) {if len(req.Tag) > 0 {- taginfo, has, err := qs.tagCommon.GetTagListByName(ctx, req.Tag)+ tagInfo, has, err := qs.tagCommon.GetTagBySlugName(ctx, strings.ToLower(req.Tag))if err != nil {log.Error("tagCommon.GetTagListByNames error", err)}if has {- req.TagIDs = append(req.TagIDs, taginfo.ID)+ req.TagIDs = append(req.TagIDs, tagInfo.ID)}-}list := make([]*schema.QuestionInfo, 0)if req.UserName != "" {diff --git a/internal/service/search/tag.go b/internal/service/search/tag.goindex 2335faa5..806880f0 100644--- a/internal/service/search/tag.go+++ b/internal/service/search/tag.go@@ -9,27 +9,28 @@ import ("github.com/answerdev/answer/internal/schema""github.com/answerdev/answer/internal/service/activity_common""github.com/answerdev/answer/internal/service/search_common"- tagcommon "github.com/answerdev/answer/internal/service/tag_common"+ "github.com/answerdev/answer/internal/service/tag_common")type TagSearch struct {- repo search_common.SearchRepo- tagRepo tagcommon.TagCommonRepo- followCommon activity_common.FollowRepo- page int- size int- exp string- w string- userID string- Extra schema.GetTagPageResp- order string+ repo search_common.SearchRepo+ tagCommonService *tag_common.TagCommonService+ followCommon activity_common.FollowRepo+ page int+ size int+ exp string+ w string+ userID string+ Extra schema.GetTagPageResp+ order string}-func NewTagSearch(repo search_common.SearchRepo, tagRepo tagcommon.TagCommonRepo, followCommon activity_common.FollowRepo) *TagSearch {+func NewTagSearch(repo search_common.SearchRepo,+ tagCommonService *tag_common.TagCommonService, followCommon activity_common.FollowRepo) *TagSearch {return &TagSearch{- repo: repo,- tagRepo: tagRepo,- followCommon: followCommon,+ repo: repo,+ tagCommonService: tagCommonService,+ followCommon: followCommon,}}@@ -65,7 +66,7 @@ func (ts *TagSearch) Search(ctx context.Context) (resp []schema.SearchResp, totatag *entity.Tagexists, followed bool)- tag, exists, err = ts.tagRepo.GetTagBySlugName(ctx, ts.exp)+ tag, exists, err = ts.tagCommonService.GetTagBySlugName(ctx, ts.exp)if err != nil {return}diff --git a/internal/service/search_service.go b/internal/service/search_service.goindex 0839d516..582984ad 100644--- a/internal/service/search_service.go+++ b/internal/service/search_service.go@@ -7,7 +7,7 @@ import ("github.com/answerdev/answer/internal/service/activity_common""github.com/answerdev/answer/internal/service/search""github.com/answerdev/answer/internal/service/search_common"- tagcommon "github.com/answerdev/answer/internal/service/tag_common"+ "github.com/answerdev/answer/internal/service/tag_common"usercommon "github.com/answerdev/answer/internal/service/user_common")@@ -34,13 +34,13 @@ type SearchService struct {func NewSearchService(searchRepo search_common.SearchRepo,- tagRepo tagcommon.TagCommonRepo,+ tagCommonService *tag_common.TagCommonService,userCommon *usercommon.UserCommon,followCommon activity_common.FollowRepo,) *SearchService {return &SearchService{searchRepo: searchRepo,- tagSearch: search.NewTagSearch(searchRepo, tagRepo, followCommon),+ tagSearch: search.NewTagSearch(searchRepo, tagCommonService, followCommon),withinSearch: search.NewWithinSearch(searchRepo),authorSearch: search.NewAuthorSearch(searchRepo, userCommon),scoreSearch: search.NewScoreSearch(searchRepo),diff --git a/internal/service/tag/tag_service.go b/internal/service/tag/tag_service.goindex dc5729d5..dcf02029 100644--- a/internal/service/tag/tag_service.go+++ b/internal/service/tag/tag_service.go@@ -6,6 +6,7 @@ import ("github.com/answerdev/answer/internal/service/revision_common""github.com/answerdev/answer/internal/service/siteinfo_common"+ "github.com/answerdev/answer/internal/service/tag_common""github.com/answerdev/answer/pkg/htmltext""github.com/answerdev/answer/internal/base/pager"@@ -14,7 +15,6 @@ import ("github.com/answerdev/answer/internal/schema""github.com/answerdev/answer/internal/service/activity_common""github.com/answerdev/answer/internal/service/permission"- tagcommon "github.com/answerdev/answer/internal/service/tag_common""github.com/answerdev/answer/pkg/converter""github.com/jinzhu/copier""github.com/segmentfault/pacman/errors"@@ -30,26 +30,26 @@ type TagRepo interface {// TagService user servicetype TagService struct {- tagRepo TagRepo- tagCommonRepo tagcommon.TagCommonRepo- revisionService *revision_common.RevisionService- followCommon activity_common.FollowRepo- siteInfoService *siteinfo_common.SiteInfoCommonService+ tagRepo TagRepo+ tagCommonService *tag_common.TagCommonService+ revisionService *revision_common.RevisionService+ followCommon activity_common.FollowRepo+ siteInfoService *siteinfo_common.SiteInfoCommonService}// NewTagService new tag servicefunc NewTagService(tagRepo TagRepo,- tagCommonRepo tagcommon.TagCommonRepo,+ tagCommonService *tag_common.TagCommonService,revisionService *revision_common.RevisionService,followCommon activity_common.FollowRepo,siteInfoService *siteinfo_common.SiteInfoCommonService) *TagService {return &TagService{- tagRepo: tagRepo,- tagCommonRepo: tagCommonRepo,- revisionService: revisionService,- followCommon: followCommon,- siteInfoService: siteInfoService,+ tagRepo: tagRepo,+ tagCommonService: tagCommonService,+ revisionService: revisionService,+ followCommon: followCommon,+ siteInfoService: siteInfoService,}}@@ -74,7 +74,7 @@ func (ts *TagService) UpdateTag(ctx context.Context, req *schema.UpdateTagReq) (return err}- tagInfo, exist, err := ts.tagCommonRepo.GetTagByID(ctx, req.TagID)+ tagInfo, exist, err := ts.tagCommonService.GetTagByID(ctx, req.TagID)if err != nil {return err}@@ -119,9 +119,9 @@ func (ts *TagService) GetTagInfo(ctx context.Context, req *schema.GetTagInfoReq)exist bool)if len(req.ID) > 0 {- tagInfo, exist, err = ts.tagCommonRepo.GetTagByID(ctx, req.ID)+ tagInfo, exist, err = ts.tagCommonService.GetTagByID(ctx, req.ID)} else {- tagInfo, exist, err = ts.tagCommonRepo.GetTagBySlugName(ctx, req.Name)+ tagInfo, exist, err = ts.tagCommonService.GetTagBySlugName(ctx, req.Name)}if err != nil {return nil, err@@ -133,7 +133,7 @@ func (ts *TagService) GetTagInfo(ctx context.Context, req *schema.GetTagInfoReq)resp = &schema.GetTagResp{}// if tag is synonyms get original tag infoif tagInfo.MainTagID > 0 {- tagInfo, exist, err = ts.tagCommonRepo.GetTagByID(ctx, converter.IntToString(tagInfo.MainTagID))+ tagInfo, exist, err = ts.tagCommonService.GetTagByID(ctx, converter.IntToString(tagInfo.MainTagID))if err != nil {return nil, err}@@ -170,7 +170,7 @@ func (ts *TagService) GetFollowingTags(ctx context.Context, userID string) (if err != nil {return nil, err}- tagList, err := ts.tagCommonRepo.GetTagListByIDs(ctx, objIDs)+ tagList, err := ts.tagCommonService.GetTagListByIDs(ctx, objIDs)if err != nil {return nil, err}@@ -183,7 +183,7 @@ func (ts *TagService) GetFollowingTags(ctx context.Context, userID string) (Reserved: t.Reserved,}if t.MainTagID > 0 {- mainTag, exist, err := ts.tagCommonRepo.GetTagByID(ctx, converter.IntToString(t.MainTagID))+ mainTag, exist, err := ts.tagCommonService.GetTagByID(ctx, converter.IntToString(t.MainTagID))if err != nil {return nil, err}@@ -199,7 +199,7 @@ func (ts *TagService) GetFollowingTags(ctx context.Context, userID string) (// GetTagSynonyms get tag synonymsfunc (ts *TagService) GetTagSynonyms(ctx context.Context, req *schema.GetTagSynonymsReq) (resp []*schema.GetTagSynonymsResp, err error) {- tag, exist, err := ts.tagCommonRepo.GetTagByID(ctx, req.TagID)+ tag, exist, err := ts.tagCommonService.GetTagByID(ctx, req.TagID)if err != nil {return}@@ -248,7 +248,7 @@ func (ts *TagService) UpdateTagSynonym(ctx context.Context, req *schema.UpdateTareq.Format()addSynonymTagList := make([]string, 0)removeSynonymTagList := make([]string, 0)- mainTagInfo, exist, err := ts.tagCommonRepo.GetTagByID(ctx, req.TagID)+ mainTagInfo, exist, err := ts.tagCommonService.GetTagByID(ctx, req.TagID)if err != nil {return err}@@ -260,7 +260,7 @@ func (ts *TagService) UpdateTagSynonym(ctx context.Context, req *schema.UpdateTafor _, item := range req.SynonymTagList {addSynonymTagList = append(addSynonymTagList, item.SlugName)}- tagListInDB, err := ts.tagCommonRepo.GetTagListByNames(ctx, addSynonymTagList)+ tagListInDB, err := ts.tagCommonService.GetTagListByNames(ctx, addSynonymTagList)if err != nil {return err}@@ -285,7 +285,7 @@ func (ts *TagService) UpdateTagSynonym(ctx context.Context, req *schema.UpdateTa}if len(needAddTagList) > 0 {- err = ts.tagCommonRepo.AddTagList(ctx, needAddTagList)+ err = ts.tagCommonService.AddTagList(ctx, needAddTagList)if err != nil {return err}@@ -343,7 +343,7 @@ func (ts *TagService) GetTagWithPage(ctx context.Context, req *schema.GetTagWithpage := req.PagepageSize := req.PageSize- tags, total, err := ts.tagCommonRepo.GetTagPage(ctx, page, pageSize, tag, req.QueryCond)+ tags, total, err := ts.tagCommonService.GetTagPage(ctx, page, pageSize, tag, req.QueryCond)if err != nil {return}diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.goindex b14b9476..dda1c923 100644--- a/internal/service/tag_common/tag_common.go+++ b/internal/service/tag_common/tag_common.go@@ -68,6 +68,7 @@ func (ts *TagCommonService) SearchTagLike(ctx context.Context, req *schema.Searcif err != nil {return}+ ts.tagsFormatRecommendAndReserved(ctx, tags)for _, tag := range tags {item := schema.SearchTagLikeResp{}item.SlugName = tag.SlugName@@ -151,17 +152,16 @@ func (ts *TagCommonService) SetTagsAttribute(ctx context.Context, tags []string,return nil}-// GetTagListByName-func (ts *TagCommonService) GetTagListByName(ctx context.Context, tagName string) (tagInfo *entity.Tag, exist bool, err error) {- tagName = strings.ToLower(tagName)- return ts.tagCommonRepo.GetTagBySlugName(ctx, tagName)-}-func (ts *TagCommonService) GetTagListByNames(ctx context.Context, tagNames []string) ([]*entity.Tag, error) {for k, tagname := range tagNames {tagNames[k] = strings.ToLower(tagname)}- return ts.tagCommonRepo.GetTagListByNames(ctx, tagNames)+ tagList, err := ts.tagCommonRepo.GetTagListByNames(ctx, tagNames)+ if err != nil {+ return nil, err+ }+ ts.tagsFormatRecommendAndReserved(ctx, tagList)+ return tagList, nil}func (ts *TagCommonService) ExistRecommend(ctx context.Context, tags []*schema.TagItem) (bool, error) {@@ -194,6 +194,52 @@ func (ts *TagCommonService) GetObjectTag(ctx context.Context, objectId string) (return ts.TagFormat(ctx, tagsInfoList)}+// AddTagList get object tag+func (ts *TagCommonService) AddTagList(ctx context.Context, tagList []*entity.Tag) (err error) {+ return ts.tagCommonRepo.AddTagList(ctx, tagList)+}++// GetTagByID get object tag+func (ts *TagCommonService) GetTagByID(ctx context.Context, tagID string) (tag *entity.Tag, exist bool, err error) {+ tag, exist, err = ts.tagCommonRepo.GetTagByID(ctx, tagID)+ if !exist {+ return+ }+ ts.tagFormatRecommendAndReserved(ctx, tag)+ return+}++// GetTagBySlugName get object tag+func (ts *TagCommonService) GetTagBySlugName(ctx context.Context, slugName string) (tag *entity.Tag, exist bool, err error) {+ tag, exist, err = ts.tagCommonRepo.GetTagBySlugName(ctx, slugName)+ if !exist {+ return+ }+ ts.tagFormatRecommendAndReserved(ctx, tag)+ return+}++// GetTagListByIDs get object tag+func (ts *TagCommonService) GetTagListByIDs(ctx context.Context, ids []string) (tagList []*entity.Tag, err error) {+ tagList, err = ts.tagCommonRepo.GetTagListByIDs(ctx, ids)+ if err != nil {+ return nil, err+ }+ ts.tagsFormatRecommendAndReserved(ctx, tagList)+ return+}++// GetTagPage get object tag+func (ts *TagCommonService) GetTagPage(ctx context.Context, page, pageSize int, tag *entity.Tag, queryCond string) (+ tagList []*entity.Tag, total int64, err error) {+ tagList, total, err = ts.tagCommonRepo.GetTagPage(ctx, page, pageSize, tag, queryCond)+ if err != nil {+ return nil, 0, err+ }+ ts.tagsFormatRecommendAndReserved(ctx, tagList)+ return+}+func (ts *TagCommonService) GetObjectEntityTag(ctx context.Context, objectId string) (objTags []*entity.Tag, err error) {tagIDList := make([]string, 0)tagList, err := ts.tagRelRepo.GetObjectTagRelList(ctx, objectId)@@ -203,11 +249,10 @@ func (ts *TagCommonService) GetObjectEntityTag(ctx context.Context, objectId strfor _, tag := range tagList {tagIDList = append(tagIDList, tag.TagID)}- objTags, err = ts.tagCommonRepo.GetTagListByIDs(ctx, tagIDList)+ objTags, err = ts.GetTagListByIDs(ctx, tagIDList)if err != nil {return nil, err}-return objTags, nil}@@ -225,6 +270,30 @@ func (ts *TagCommonService) TagFormat(ctx context.Context, tags []*entity.Tag) (return objTags, nil}+func (ts *TagCommonService) tagsFormatRecommendAndReserved(ctx context.Context, tagList []*entity.Tag) {+ tagConfig, err := ts.siteInfoService.GetSiteWrite(ctx)+ if err != nil {+ log.Error(err)+ return+ }+ if !tagConfig.RequiredTag {+ for _, tag := range tagList {+ tag.Recommend = false+ }+ }+}++func (ts *TagCommonService) tagFormatRecommendAndReserved(ctx context.Context, tag *entity.Tag) {+ tagConfig, err := ts.siteInfoService.GetSiteWrite(ctx)+ if err != nil {+ log.Error(err)+ return+ }+ if !tagConfig.RequiredTag {+ tag.Recommend = false+ }+}+// BatchGetObjectTag batch get object tagfunc (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []string) (map[string][]*schema.TagResp, error) {objectIDTagMap := make(map[string][]*schema.TagResp)@@ -238,7 +307,7 @@ func (ts *TagCommonService) BatchGetObjectTag(ctx context.Context, objectIds []sfor _, tag := range tagList {tagIDList = append(tagIDList, tag.TagID)}- tagsInfoList, err := ts.tagCommonRepo.GetTagListByIDs(ctx, tagIDList)+ tagsInfoList, err := ts.GetTagListByIDs(ctx, tagIDList)if err != nil {return objectIDTagMap, err}@@ -275,14 +344,8 @@ func (ts *TagCommonService) CheckTag(ctx context.Context, tags []string, userIDreturn nil}- thisTagNameList := make([]string, 0)- for _, t := range tags {- t = strings.ToLower(t)- thisTagNameList = append(thisTagNameList, t)- }-// find tags name- tagListInDb, err := ts.tagCommonRepo.GetTagListByNames(ctx, thisTagNameList)+ tagListInDb, err := ts.GetTagListByNames(ctx, tags)if err != nil {return err}