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.
GetUnreviewedRevisionList
aichy126a923e6f0b4e4
diff --git a/cmd/answer/wire_gen.go b/cmd/answer/wire_gen.goindex 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.goindex 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 responsetype GetRevisionResp struct {// iddiff --git a/internal/service/revision_service.go b/internal/service/revision_service.goindex 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 servicetype 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