From 6202877bdc5ace47ee7fa090dae596e39dec91cd Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:27:35 +0800 Subject: [PATCH 1/3] GetUnreviewedRevisionList --- docs/docs.go | 44 ++++++++++++++++++++++ docs/swagger.json | 44 ++++++++++++++++++++++ docs/swagger.yaml | 26 +++++++++++++ internal/controller/revision_controller.go | 22 +++++++++++ internal/entity/revision_entity.go | 4 ++ internal/repo/revision/revision_repo.go | 22 +++++++++++ internal/router/answer_api_router.go | 1 + internal/schema/revision_schema.go | 4 ++ internal/service/revision/revision.go | 1 + internal/service/revision_service.go | 14 +++++++ 10 files changed, 182 insertions(+) diff --git a/docs/docs.go b/docs/docs.go index 017b0a49..5a5baf7f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -3069,6 +3069,50 @@ const docTemplate = `{ } } }, + "/answer/api/v1/revisions/unreviewed": { + "get": { + "description": "get unreviewed revision list", + "produces": [ + "application/json" + ], + "tags": [ + "Revision" + ], + "summary": "get unreviewed revision list", + "parameters": [ + { + "type": "string", + "description": "page id", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/handler.RespBody" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.GetRevisionResp" + } + } + } + } + ] + } + } + } + } + }, "/answer/api/v1/search": { "get": { "security": [ diff --git a/docs/swagger.json b/docs/swagger.json index 7d0ba920..c4deea23 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -3057,6 +3057,50 @@ } } }, + "/answer/api/v1/revisions/unreviewed": { + "get": { + "description": "get unreviewed revision list", + "produces": [ + "application/json" + ], + "tags": [ + "Revision" + ], + "summary": "get unreviewed revision list", + "parameters": [ + { + "type": "string", + "description": "page id", + "name": "page", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/handler.RespBody" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/schema.GetRevisionResp" + } + } + } + } + ] + } + } + } + } + }, "/answer/api/v1/search": { "get": { "security": [ diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 8b644499..4e1a2898 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3494,6 +3494,32 @@ paths: summary: get revision list tags: - Revision + /answer/api/v1/revisions/unreviewed: + get: + description: get unreviewed revision list + parameters: + - description: page id + in: query + name: page + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/handler.RespBody' + - properties: + data: + items: + $ref: '#/definitions/schema.GetRevisionResp' + type: array + type: object + summary: get unreviewed revision list + tags: + - Revision /answer/api/v1/search: get: description: search object diff --git a/internal/controller/revision_controller.go b/internal/controller/revision_controller.go index 5f30b70e..3c0c6c1b 100644 --- a/internal/controller/revision_controller.go +++ b/internal/controller/revision_controller.go @@ -5,6 +5,7 @@ import ( "github.com/answerdev/answer/internal/base/reason" "github.com/answerdev/answer/internal/schema" "github.com/answerdev/answer/internal/service" + "github.com/answerdev/answer/pkg/converter" "github.com/gin-gonic/gin" "github.com/segmentfault/pacman/errors" ) @@ -41,3 +42,24 @@ func (rc *RevisionController) GetRevisionList(ctx *gin.Context) { resp, err := rc.revisionListService.GetRevisionList(ctx, req) handler.HandleResponse(ctx, err, resp) } + +// GetUnreviewedRevisionList godoc +// @Summary get unreviewed revision list +// @Description get unreviewed revision list +// @Tags Revision +// @Produce json +// @Param page query string true "page id" +// @Success 200 {object} handler.RespBody{data=[]schema.GetRevisionResp} +// @Router /answer/api/v1/revisions/unreviewed [get] +func (rc *RevisionController) GetUnreviewedRevisionList(ctx *gin.Context) { + pageStr := ctx.Query("page") + page := converter.StringToInt(pageStr) + req := &schema.RevisionSearch{ + Page: page, + } + resp, count, err := rc.revisionListService.GetUnreviewedRevisionList(ctx, req) + handler.HandleResponse(ctx, err, gin.H{ + "list": resp, + "count": count, + }) +} diff --git a/internal/entity/revision_entity.go b/internal/entity/revision_entity.go index f2e91514..09c5e815 100644 --- a/internal/entity/revision_entity.go +++ b/internal/entity/revision_entity.go @@ -26,6 +26,10 @@ type Revision struct { ReviewUserID int64 `xorm:"not null default 0 BIGINT(20) review_user_id"` } +type RevisionSearch struct { + Page int `json:"page" form:"page"` // Query number of pages +} + // TableName revision table name func (Revision) TableName() string { return "revision" diff --git a/internal/repo/revision/revision_repo.go b/internal/repo/revision/revision_repo.go index 1545d7fa..b0d3d5f6 100644 --- a/internal/repo/revision/revision_repo.go +++ b/internal/repo/revision/revision_repo.go @@ -149,3 +149,25 @@ func (rr *revisionRepo) allowRecord(objectType int) (ok bool) { return false } } + +func (rr *revisionRepo) SearchUnreviewedList(ctx context.Context, search *entity.RevisionSearch) ([]*entity.Revision, int64, error) { + var count int64 + var err error + rows := make([]*entity.Revision, 0) + if search.Page > 0 { + search.Page = search.Page - 1 + } else { + search.Page = 0 + } + PageSize := 1 + offset := search.Page * PageSize + session := rr.data.DB.Where("") + session = session.And("status = ?", entity.RevisionUnreviewedStatus) + session = session.OrderBy("created_at desc") + session = session.Limit(PageSize, offset) + count, err = session.FindAndCount(&rows) + if err != nil { + return rows, count, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() + } + return rows, count, nil +} diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.go index 2fa6ccfe..d798e4b1 100644 --- a/internal/router/answer_api_router.go +++ b/internal/router/answer_api_router.go @@ -123,6 +123,7 @@ func (a *AnswerAPIRouter) RegisterUnAuthAnswerAPIRouter(r *gin.RouterGroup) { //revision r.GET("/revisions", a.revisionController.GetRevisionList) + r.GET("/revisions/unreviewed", a.revisionController.GetUnreviewedRevisionList) // tag r.GET("/tags/page", a.tagController.GetTagWithPage) diff --git a/internal/schema/revision_schema.go b/internal/schema/revision_schema.go index 9afe3454..09ed274b 100644 --- a/internal/schema/revision_schema.go +++ b/internal/schema/revision_schema.go @@ -26,6 +26,10 @@ type GetRevisionListReq struct { ObjectID string `validate:"required" comment:"object_id" form:"object_id"` } +type RevisionSearch struct { + Page int `json:"page" form:"page"` // Query number of pages +} + // GetRevisionResp get revision response type GetRevisionResp struct { // id diff --git a/internal/service/revision/revision.go b/internal/service/revision/revision.go index cbac464f..1bc76fff 100644 --- a/internal/service/revision/revision.go +++ b/internal/service/revision/revision.go @@ -15,4 +15,5 @@ type RevisionRepo interface { GetRevisionList(ctx context.Context, revision *entity.Revision) (revisionList []entity.Revision, err error) UpdateObjectRevisionId(ctx context.Context, revision *entity.Revision, session *xorm.Session) (err error) ExistUnreviewedByObjectID(ctx context.Context, objectID string) (revision *entity.Revision, exist bool, err error) + SearchUnreviewedList(ctx context.Context, search *entity.RevisionSearch) ([]*entity.Revision, int64, error) } diff --git a/internal/service/revision_service.go b/internal/service/revision_service.go index fe9da647..0102d761 100644 --- a/internal/service/revision_service.go +++ b/internal/service/revision_service.go @@ -10,6 +10,7 @@ import ( questioncommon "github.com/answerdev/answer/internal/service/question_common" "github.com/answerdev/answer/internal/service/revision" usercommon "github.com/answerdev/answer/internal/service/user_common" + "github.com/davecgh/go-spew/spew" "github.com/jinzhu/copier" ) @@ -34,6 +35,19 @@ func NewRevisionService( } } +// SearchUnreviewedList get unreviewed list +func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []schema.GetRevisionResp, count int64, err error) { + resp = []schema.GetRevisionResp{} + search := &entity.RevisionSearch{} + _ = copier.Copy(search, req) + list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search) + for _, item := range list { + spew.Dump(item) + } + + return +} + // GetRevisionList get revision list all func (rs *RevisionService) GetRevisionList(ctx context.Context, req *schema.GetRevisionListReq) (resp []schema.GetRevisionResp, err error) { var ( From a923e6f0b4e402bac8e95d4d69fc5cc50c0b1c53 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 23 Nov 2022 16:52:27 +0800 Subject: [PATCH 2/3] GetUnreviewedRevisionList --- cmd/answer/wire_gen.go | 2 +- internal/schema/revision_schema.go | 4 +++ internal/service/revision_service.go | 40 +++++++++++++++++++--------- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.go index 21b1022e..c6bc7999 100644 --- a/cmd/answer/wire_gen.go +++ b/cmd/answer/wire_gen.go @@ -163,7 +163,7 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, searchRepo := search_common.NewSearchRepo(dataData, uniqueIDRepo, userCommon) searchService := service.NewSearchService(searchParser, searchRepo) searchController := controller.NewSearchController(searchService) - serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService) + serviceRevisionService := service.NewRevisionService(revisionRepo, userCommon, questionCommon, answerService, objService) revisionController := controller.NewRevisionController(serviceRevisionService) rankController := controller.NewRankController(rankService) commonRepo := common.NewCommonRepo(dataData, uniqueIDRepo) diff --git a/internal/schema/revision_schema.go b/internal/schema/revision_schema.go index 09ed274b..2bda608c 100644 --- a/internal/schema/revision_schema.go +++ b/internal/schema/revision_schema.go @@ -30,6 +30,10 @@ type RevisionSearch struct { Page int `json:"page" form:"page"` // Query number of pages } +type GetUnreviewedRevisionResp struct { + Type string `json:"type"` +} + // GetRevisionResp get revision response type GetRevisionResp struct { // id diff --git a/internal/service/revision_service.go b/internal/service/revision_service.go index 0102d761..64e2d9bf 100644 --- a/internal/service/revision_service.go +++ b/internal/service/revision_service.go @@ -7,6 +7,7 @@ import ( "github.com/answerdev/answer/internal/base/constant" "github.com/answerdev/answer/internal/entity" "github.com/answerdev/answer/internal/schema" + "github.com/answerdev/answer/internal/service/object_info" questioncommon "github.com/answerdev/answer/internal/service/question_common" "github.com/answerdev/answer/internal/service/revision" usercommon "github.com/answerdev/answer/internal/service/user_common" @@ -16,33 +17,46 @@ import ( // RevisionService user service type RevisionService struct { - revisionRepo revision.RevisionRepo - userCommon *usercommon.UserCommon - questionCommon *questioncommon.QuestionCommon - answerService *AnswerService + revisionRepo revision.RevisionRepo + userCommon *usercommon.UserCommon + questionCommon *questioncommon.QuestionCommon + answerService *AnswerService + objectInfoService *object_info.ObjService } func NewRevisionService( revisionRepo revision.RevisionRepo, userCommon *usercommon.UserCommon, questionCommon *questioncommon.QuestionCommon, - answerService *AnswerService) *RevisionService { + answerService *AnswerService, + objectInfoService *object_info.ObjService, +) *RevisionService { return &RevisionService{ - revisionRepo: revisionRepo, - userCommon: userCommon, - questionCommon: questionCommon, - answerService: answerService, + revisionRepo: revisionRepo, + userCommon: userCommon, + questionCommon: questionCommon, + answerService: answerService, + objectInfoService: objectInfoService, } } // SearchUnreviewedList get unreviewed list -func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []schema.GetRevisionResp, count int64, err error) { - resp = []schema.GetRevisionResp{} +func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *schema.RevisionSearch) (resp []*schema.GetUnreviewedRevisionResp, count int64, err error) { + resp = []*schema.GetUnreviewedRevisionResp{} search := &entity.RevisionSearch{} _ = copier.Copy(search, req) list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search) - for _, item := range list { - spew.Dump(item) + for _, revision := range list { + spew.Dump(revision) + item := &schema.GetUnreviewedRevisionResp{} + _, ok := constant.ObjectTypeNumberMapping[revision.ObjectType] + if !ok { + continue + } + item.Type = constant.ObjectTypeNumberMapping[revision.ObjectType] + info, err := rs.objectInfoService.GetInfo(ctx, revision.ObjectID) + spew.Dump(info, err) + resp = append(resp, item) } return From 3cd52758f3d28185747be5b4a3ee3044f8e65d25 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 23 Nov 2022 18:10:34 +0800 Subject: [PATCH 3/3] update unreviewed revision --- cmd/answer/wire_gen.go | 10 +-- internal/schema/revision_schema.go | 4 +- internal/schema/simple_obj_info_schema.go | 8 ++ internal/service/object_info/object_info.go | 81 +++++++++++++++++++- internal/service/question_common/question.go | 14 ++++ internal/service/revision_service.go | 18 +++-- internal/service/tag_common/tag_common.go | 10 +-- 7 files changed, 126 insertions(+), 19 deletions(-) diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.go index c6bc7999..36e44755 100644 --- a/cmd/answer/wire_gen.go +++ b/cmd/answer/wire_gen.go @@ -120,7 +120,11 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, answerRepo := answer.NewAnswerRepo(dataData, uniqueIDRepo, userRankRepo, activityRepo) questionRepo := question.NewQuestionRepo(dataData, uniqueIDRepo) tagCommonRepo := tag_common.NewTagCommonRepo(dataData, uniqueIDRepo) - objService := object_info.NewObjService(answerRepo, questionRepo, commentCommonRepo, tagCommonRepo) + tagRelRepo := tag.NewTagRelRepo(dataData) + revisionRepo := revision.NewRevisionRepo(dataData, uniqueIDRepo) + revisionService := revision_common.NewRevisionService(revisionRepo, userRepo) + tagCommonService := tag_common2.NewTagCommonService(tagCommonRepo, tagRelRepo, revisionService, siteInfoCommonService) + objService := object_info.NewObjService(answerRepo, questionRepo, commentCommonRepo, tagCommonRepo, tagCommonService) voteRepo := activity_common.NewVoteRepo(dataData, activityRepo) commentService := comment2.NewCommentService(commentRepo, commentCommonRepo, userCommon, objService, voteRepo) rankService := rank2.NewRankService(userCommon, userRankRepo, objService, configRepo) @@ -132,10 +136,6 @@ func initApplication(debug bool, serverConf *conf.Server, dbConf *data.Database, voteService := service.NewVoteService(serviceVoteRepo, uniqueIDRepo, configRepo, questionRepo, answerRepo, commentCommonRepo, objService) voteController := controller.NewVoteController(voteService) 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, tagCommonService, revisionService, followRepo, siteInfoCommonService) tagController := controller.NewTagController(tagService, tagCommonService, rankService) diff --git a/internal/schema/revision_schema.go b/internal/schema/revision_schema.go index 2bda608c..e4141d65 100644 --- a/internal/schema/revision_schema.go +++ b/internal/schema/revision_schema.go @@ -31,7 +31,9 @@ type RevisionSearch struct { } type GetUnreviewedRevisionResp struct { - Type string `json:"type"` + Type string `json:"type"` + Info *UnreviewedRevisionInfoInfo `json:"info"` + UnreviewedInfo *GetRevisionResp `json:"unreviewed_info"` } // GetRevisionResp get revision response diff --git a/internal/schema/simple_obj_info_schema.go b/internal/schema/simple_obj_info_schema.go index 312772db..678ebb6c 100644 --- a/internal/schema/simple_obj_info_schema.go +++ b/internal/schema/simple_obj_info_schema.go @@ -12,3 +12,11 @@ type SimpleObjectInfo struct { Title string `json:"title"` Content string `json:"content"` } + +type UnreviewedRevisionInfoInfo struct { + ObjectID string `json:"object_id"` + Title string `json:"title"` + Content string `json:"content"` + Html string `json:"html"` + Tags []*TagResp `json:"tags"` +} diff --git a/internal/service/object_info/object_info.go b/internal/service/object_info/object_info.go index aea2208d..b6cf3298 100644 --- a/internal/service/object_info/object_info.go +++ b/internal/service/object_info/object_info.go @@ -20,6 +20,7 @@ type ObjService struct { questionRepo questioncommon.QuestionRepo commentRepo comment_common.CommentCommonRepo tagRepo tagcommon.TagCommonRepo + tagCommon *tagcommon.TagCommonService } // NewObjService new object service @@ -27,14 +28,92 @@ func NewObjService( answerRepo answercommon.AnswerRepo, questionRepo questioncommon.QuestionRepo, commentRepo comment_common.CommentCommonRepo, - tagRepo tagcommon.TagCommonRepo) *ObjService { + tagRepo tagcommon.TagCommonRepo, + tagCommon *tagcommon.TagCommonService, +) *ObjService { return &ObjService{ answerRepo: answerRepo, questionRepo: questionRepo, commentRepo: commentRepo, tagRepo: tagRepo, + tagCommon: tagCommon, } } +func (os *ObjService) GetUnreviewedRevisionInfo(ctx context.Context, objectID string) (objInfo *schema.UnreviewedRevisionInfoInfo, err error) { + objInfo = &schema.UnreviewedRevisionInfoInfo{} + + objectType, err := obj.GetObjectTypeStrByObjectID(objectID) + if err != nil { + return nil, err + } + switch objectType { + case constant.QuestionObjectType: + questionInfo, exist, err := os.questionRepo.GetQuestion(ctx, objectID) + if err != nil { + return nil, err + } + if !exist { + break + } + taglist, err := os.tagCommon.GetObjectEntityTag(ctx, objectID) + if err != nil { + return nil, err + } + os.tagCommon.TagsFormatRecommendAndReserved(ctx, taglist) + tags, err := os.tagCommon.TagFormat(ctx, taglist) + if err != nil { + return nil, err + } + objInfo = &schema.UnreviewedRevisionInfoInfo{ + ObjectID: questionInfo.ID, + Title: questionInfo.Title, + Content: questionInfo.OriginalText, + Html: questionInfo.ParsedText, + Tags: tags, + } + case constant.AnswerObjectType: + answerInfo, exist, err := os.answerRepo.GetAnswer(ctx, objectID) + if err != nil { + return nil, err + } + if !exist { + break + } + + questionInfo, exist, err := os.questionRepo.GetQuestion(ctx, answerInfo.QuestionID) + if err != nil { + return nil, err + } + if !exist { + break + } + objInfo = &schema.UnreviewedRevisionInfoInfo{ + ObjectID: answerInfo.ID, + Title: questionInfo.Title, + Content: answerInfo.OriginalText, + Html: answerInfo.ParsedText, + } + + case constant.TagObjectType: + tagInfo, exist, err := os.tagRepo.GetTagByID(ctx, objectID) + if err != nil { + return nil, err + } + if !exist { + break + } + objInfo = &schema.UnreviewedRevisionInfoInfo{ + ObjectID: tagInfo.ID, + Title: tagInfo.SlugName, + Content: tagInfo.OriginalText, + Html: tagInfo.ParsedText, + } + } + if objInfo == nil { + err = errors.BadRequest(reason.ObjectNotFound) + } + return objInfo, err +} // GetInfo get object simple information func (os *ObjService) GetInfo(ctx context.Context, objectID string) (objInfo *schema.SimpleObjectInfo, err error) { diff --git a/internal/service/question_common/question.go b/internal/service/question_common/question.go index 9677cb1c..479238eb 100644 --- a/internal/service/question_common/question.go +++ b/internal/service/question_common/question.go @@ -386,3 +386,17 @@ func (qs *QuestionCommon) ShowFormat(ctx context.Context, data *entity.Question) info.Tags = make([]*schema.TagResp, 0) return &info } +func (qs *QuestionCommon) ShowFormatWithTag(ctx context.Context, data *entity.QuestionWithTagsRevision) *schema.QuestionInfo { + info := qs.ShowFormat(ctx, &data.Question) + Tags := make([]*schema.TagResp, 0) + for _, tag := range data.Tags { + item := &schema.TagResp{} + item.SlugName = tag.SlugName + item.DisplayName = tag.DisplayName + item.Recommend = tag.Recommend + item.Reserved = tag.Reserved + Tags = append(Tags, item) + } + info.Tags = Tags + return info +} diff --git a/internal/service/revision_service.go b/internal/service/revision_service.go index 64e2d9bf..d73ad878 100644 --- a/internal/service/revision_service.go +++ b/internal/service/revision_service.go @@ -11,7 +11,6 @@ import ( questioncommon "github.com/answerdev/answer/internal/service/question_common" "github.com/answerdev/answer/internal/service/revision" usercommon "github.com/answerdev/answer/internal/service/user_common" - "github.com/davecgh/go-spew/spew" "github.com/jinzhu/copier" ) @@ -47,18 +46,23 @@ func (rs *RevisionService) GetUnreviewedRevisionList(ctx context.Context, req *s _ = copier.Copy(search, req) list, count, err := rs.revisionRepo.SearchUnreviewedList(ctx, search) for _, revision := range list { - spew.Dump(revision) item := &schema.GetUnreviewedRevisionResp{} _, ok := constant.ObjectTypeNumberMapping[revision.ObjectType] if !ok { continue } item.Type = constant.ObjectTypeNumberMapping[revision.ObjectType] - info, err := rs.objectInfoService.GetInfo(ctx, revision.ObjectID) - spew.Dump(info, err) + info, infoerr := rs.objectInfoService.GetUnreviewedRevisionInfo(ctx, revision.ObjectID) + if infoerr != nil { + return resp, 0, infoerr + } + item.Info = info + revisionitem := &schema.GetRevisionResp{} + _ = copier.Copy(revisionitem, revision) + rs.parseItem(ctx, revisionitem) + item.UnreviewedInfo = revisionitem resp = append(resp, item) } - return } @@ -103,7 +107,7 @@ func (rs *RevisionService) GetRevisionList(ctx context.Context, req *schema.GetR func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisionResp) { var ( err error - question entity.Question + question entity.QuestionWithTagsRevision questionInfo *schema.QuestionInfo answer entity.Answer answerInfo *schema.AnswerInfo @@ -117,7 +121,7 @@ func (rs *RevisionService) parseItem(ctx context.Context, item *schema.GetRevisi if err != nil { break } - questionInfo = rs.questionCommon.ShowFormat(ctx, &question) + questionInfo = rs.questionCommon.ShowFormatWithTag(ctx, &question) item.ContentParsed = questionInfo case constant.ObjectTypeStrMapping["answer"]: err = json.Unmarshal([]byte(item.Content), &answer) diff --git a/internal/service/tag_common/tag_common.go b/internal/service/tag_common/tag_common.go index dc5b2c6b..e5dcbf35 100644 --- a/internal/service/tag_common/tag_common.go +++ b/internal/service/tag_common/tag_common.go @@ -70,7 +70,7 @@ func (ts *TagCommonService) SearchTagLike(ctx context.Context, req *schema.Searc if err != nil { return } - ts.tagsFormatRecommendAndReserved(ctx, tags) + ts.TagsFormatRecommendAndReserved(ctx, tags) for _, tag := range tags { item := schema.SearchTagLikeResp{} item.SlugName = tag.SlugName @@ -168,7 +168,7 @@ func (ts *TagCommonService) GetTagListByNames(ctx context.Context, tagNames []st if err != nil { return nil, err } - ts.tagsFormatRecommendAndReserved(ctx, tagList) + ts.TagsFormatRecommendAndReserved(ctx, tagList) return tagList, nil } @@ -233,7 +233,7 @@ func (ts *TagCommonService) GetTagListByIDs(ctx context.Context, ids []string) ( if err != nil { return nil, err } - ts.tagsFormatRecommendAndReserved(ctx, tagList) + ts.TagsFormatRecommendAndReserved(ctx, tagList) return } @@ -244,7 +244,7 @@ func (ts *TagCommonService) GetTagPage(ctx context.Context, page, pageSize int, if err != nil { return nil, 0, err } - ts.tagsFormatRecommendAndReserved(ctx, tagList) + ts.TagsFormatRecommendAndReserved(ctx, tagList) return } @@ -278,7 +278,7 @@ func (ts *TagCommonService) TagFormat(ctx context.Context, tags []*entity.Tag) ( return objTags, nil } -func (ts *TagCommonService) tagsFormatRecommendAndReserved(ctx context.Context, tagList []*entity.Tag) { +func (ts *TagCommonService) TagsFormatRecommendAndReserved(ctx context.Context, tagList []*entity.Tag) { if len(tagList) == 0 { return }